mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
feat: Move cross filters to Dashboard (#22785)
This commit is contained in:
@@ -41,6 +41,14 @@ interface TimeoutError {
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
type ErrorType =
|
||||
| SupersetClientResponse
|
||||
| TimeoutError
|
||||
| { response: Response }
|
||||
| string;
|
||||
|
||||
type ErrorTextSource = 'dashboard' | 'chart' | 'query' | 'dataset' | 'database';
|
||||
|
||||
export function parseErrorJson(responseObject: JsonObject): ClientErrorObject {
|
||||
let error = { ...responseObject };
|
||||
// Backwards compatibility for old error renderers with the new error object
|
||||
@@ -78,6 +86,29 @@ export function parseErrorJson(responseObject: JsonObject): ClientErrorObject {
|
||||
return { ...error, error: error.error }; // explicit ClientErrorObject
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility to get standardized error text for generic update failures
|
||||
*/
|
||||
export async function getErrorText(
|
||||
errorObject: ErrorType,
|
||||
source: ErrorTextSource,
|
||||
) {
|
||||
const { error, message } = await getClientErrorObject(errorObject);
|
||||
let errorText = t('Sorry, an unknown error occurred.');
|
||||
|
||||
if (error) {
|
||||
errorText = t(
|
||||
'Sorry, there was an error saving this %s: %s',
|
||||
source,
|
||||
error,
|
||||
);
|
||||
}
|
||||
if (typeof message === 'string' && message === 'Forbidden') {
|
||||
errorText = t('You do not have permission to edit this %s', source);
|
||||
}
|
||||
return errorText;
|
||||
}
|
||||
|
||||
export function getClientErrorObject(
|
||||
response:
|
||||
| SupersetClientResponse
|
||||
|
||||
Reference in New Issue
Block a user