mirror of https://github.com/apache/superset.git
fix: no lazy translation on SupersetError (#15669)
* fix: no lazy translation on SupersetError * Small fixes
This commit is contained in:
parent
22494b642e
commit
b489cffb57
|
@ -250,18 +250,22 @@ export function queryFailed(query, msg, link, errors) {
|
||||||
})
|
})
|
||||||
: Promise.resolve();
|
: Promise.resolve();
|
||||||
|
|
||||||
return sync
|
return (
|
||||||
.then(() => dispatch({ type: QUERY_FAILED, query, msg, link, errors }))
|
sync
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
dispatch(
|
dispatch(
|
||||||
addDangerToast(
|
addDangerToast(
|
||||||
t(
|
t(
|
||||||
'An error occurred while storing the latest query id in the backend. ' +
|
'An error occurred while storing the latest query id in the backend. ' +
|
||||||
'Please contact your administrator if this problem persists.',
|
'Please contact your administrator if this problem persists.',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
);
|
// We should always show the error message, even if we couldn't sync the
|
||||||
|
// state to the backend
|
||||||
|
.then(() => dispatch({ type: QUERY_FAILED, query, msg, link, errors }))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@ export default function setupErrorMessages() {
|
||||||
ErrorTypeEnum.GENERIC_DB_ENGINE_ERROR,
|
ErrorTypeEnum.GENERIC_DB_ENGINE_ERROR,
|
||||||
DatabaseErrorMessage,
|
DatabaseErrorMessage,
|
||||||
);
|
);
|
||||||
|
errorMessageComponentRegistry.registerValue(
|
||||||
|
ErrorTypeEnum.GENERIC_BACKEND_ERROR,
|
||||||
|
DatabaseErrorMessage,
|
||||||
|
);
|
||||||
errorMessageComponentRegistry.registerValue(
|
errorMessageComponentRegistry.registerValue(
|
||||||
ErrorTypeEnum.COLUMN_DOES_NOT_EXIST_ERROR,
|
ErrorTypeEnum.COLUMN_DOES_NOT_EXIST_ERROR,
|
||||||
DatabaseErrorMessage,
|
DatabaseErrorMessage,
|
||||||
|
|
|
@ -2038,15 +2038,17 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
database_id = data["dbId"]
|
database_id = data["dbId"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SupersetGenericErrorException(
|
raise SupersetGenericErrorException(
|
||||||
"One or more required fields are missing in the request. Please try "
|
__(
|
||||||
"again, and if the problem persists conctact your administrator.",
|
"One or more required fields are missing in the request. Please try "
|
||||||
|
"again, and if the problem persists conctact your administrator."
|
||||||
|
),
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
database = db.session.query(Database).get(database_id)
|
database = db.session.query(Database).get(database_id)
|
||||||
if not database:
|
if not database:
|
||||||
raise SupersetErrorException(
|
raise SupersetErrorException(
|
||||||
SupersetError(
|
SupersetError(
|
||||||
message="The database was not found.",
|
message=__("The database was not found."),
|
||||||
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
|
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
|
||||||
level=ErrorLevel.ERROR,
|
level=ErrorLevel.ERROR,
|
||||||
),
|
),
|
||||||
|
@ -2116,7 +2118,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
)
|
)
|
||||||
raise SupersetErrorException(
|
raise SupersetErrorException(
|
||||||
SupersetError(
|
SupersetError(
|
||||||
message="The database was not found.",
|
message=__("The database was not found."),
|
||||||
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
|
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
|
||||||
level=ErrorLevel.ERROR,
|
level=ErrorLevel.ERROR,
|
||||||
),
|
),
|
||||||
|
@ -2461,7 +2463,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
logger.exception("Query %i: %s", query.id, str(ex))
|
logger.exception("Query %i: %s", query.id, str(ex))
|
||||||
|
|
||||||
message = _("Failed to start remote query on a worker.")
|
message = __("Failed to start remote query on a worker.")
|
||||||
error = SupersetError(
|
error = SupersetError(
|
||||||
message=message,
|
message=message,
|
||||||
error_type=SupersetErrorType.ASYNC_WORKERS_ERROR,
|
error_type=SupersetErrorType.ASYNC_WORKERS_ERROR,
|
||||||
|
@ -2625,7 +2627,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
mydb = session.query(Database).get(database_id)
|
mydb = session.query(Database).get(database_id)
|
||||||
if not mydb:
|
if not mydb:
|
||||||
raise SupersetGenericErrorException(
|
raise SupersetGenericErrorException(
|
||||||
_(
|
__(
|
||||||
"The database referenced in this query was not found. Please "
|
"The database referenced in this query was not found. Please "
|
||||||
"contact an administrator for further assistance or try again."
|
"contact an administrator for further assistance or try again."
|
||||||
)
|
)
|
||||||
|
@ -2668,7 +2670,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
query_id = None
|
query_id = None
|
||||||
if not query_id:
|
if not query_id:
|
||||||
raise SupersetGenericErrorException(
|
raise SupersetGenericErrorException(
|
||||||
_(
|
__(
|
||||||
"The query record was not created as expected. Please "
|
"The query record was not created as expected. Please "
|
||||||
"contact an administrator for further assistance or try again."
|
"contact an administrator for further assistance or try again."
|
||||||
)
|
)
|
||||||
|
@ -2679,7 +2681,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
try:
|
try:
|
||||||
query.raise_for_access()
|
query.raise_for_access()
|
||||||
except SupersetSecurityException as ex:
|
except SupersetSecurityException as ex:
|
||||||
message = _(
|
message = __(
|
||||||
"You are not authorized to see this query. If you think this "
|
"You are not authorized to see this query. If you think this "
|
||||||
"is an error, please reach out to your administrator."
|
"is an error, please reach out to your administrator."
|
||||||
)
|
)
|
||||||
|
@ -2708,7 +2710,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
||||||
query.status = QueryStatus.FAILED
|
query.status = QueryStatus.FAILED
|
||||||
session.commit()
|
session.commit()
|
||||||
raise SupersetTemplateParamsErrorException(
|
raise SupersetTemplateParamsErrorException(
|
||||||
message=_(
|
message=__(
|
||||||
'The query contains one or more malformed template parameters. Please check your query and confirm that all template parameters are surround by double braces, for example, "{{ ds }}". Then, try running your query again.'
|
'The query contains one or more malformed template parameters. Please check your query and confirm that all template parameters are surround by double braces, for example, "{{ ds }}". Then, try running your query again.'
|
||||||
),
|
),
|
||||||
error=SupersetErrorType.INVALID_TEMPLATE_PARAMS_ERROR,
|
error=SupersetErrorType.INVALID_TEMPLATE_PARAMS_ERROR,
|
||||||
|
|
Loading…
Reference in New Issue