Skip to content

Commit

Permalink
refactor(anomaly detection): improve chart error message
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Oct 8, 2024
1 parent 73cfa3c commit 48c5e4d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions static/app/views/alerts/rules/metric/ruleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1099,12 +1099,20 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
this.setState(rest);
}
} catch (e) {
const chartErrorMessage =
e.responseJSON && typeof e.responseJSON === 'object'
? e.responseJSON.detail
: typeof e.responseJSON === 'string'
? e.responseJSON
: e.message || e;
let chartErrorMessage: string | undefined;
if (e.responseJSON) {
if (typeof e.responseJSON === 'object' && e.responseJSON.detail) {
chartErrorMessage = e.responseJSON.detail;
}
if (typeof e.responseJSON === 'string') {
chartErrorMessage = e.responseJSON;
}
} else if (typeof e.message === 'string') {
chartErrorMessage = e.message;
} else {
chartErrorMessage = t('Something went wrong when rendering this chart.');
}

this.setState({
chartError: true,
chartErrorMessage,
Expand Down

0 comments on commit 48c5e4d

Please sign in to comment.