Skip to content

Commit

Permalink
feat: better errors for report in charts and dashboard (apache#16131)
Browse files Browse the repository at this point in the history
* added google alert

* better errors and report actions
  • Loading branch information
AAfghahi committed Aug 9, 2021
1 parent 93e5f51 commit 68972f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion superset-frontend/src/components/ReportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const ReportModal: FunctionComponent<ReportProps> = ({
onClick={onSave}
disabled={!currentReport?.name}
>
Add
{isEditMode ? t('Save') : t('Add')}
</StyledFooterButton>
</>
);
Expand Down
15 changes: 11 additions & 4 deletions superset-frontend/src/reports/actions/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/* eslint camelcase: 0 */
import { t, SupersetClient } from '@superset-ui/core';
import rison from 'rison';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { addDangerToast, addSuccessToast } from '../../messageToasts/actions';

export const SET_REPORT = 'SET_REPORT';
Expand Down Expand Up @@ -106,11 +107,17 @@ export const addReport = report => dispatch => {
dispatch({ type: ADD_REPORT, json });
dispatch(addSuccessToast(t('The report has been created')));
})
.catch(() =>
.catch(async e => {
const parsedError = await getClientErrorObject(e);
const errorMessage = parsedError.message;
const errorArr = Object.keys(errorMessage);
const error = errorMessage[errorArr[0]][0];
dispatch(
addDangerToast(t('An error occurred while creating this report.')),
),
);
addDangerToast(
t('An error occurred while editing this report: %s', error),
),
);
});
};

export const EDIT_REPORT = 'EDIT_REPORT';
Expand Down

0 comments on commit 68972f2

Please sign in to comment.