Skip to content

Commit 48c5e4d

Browse files
committed
refactor(anomaly detection): improve chart error message
1 parent 73cfa3c commit 48c5e4d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Diff for: static/app/views/alerts/rules/metric/ruleForm.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -1099,12 +1099,20 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
10991099
this.setState(rest);
11001100
}
11011101
} catch (e) {
1102-
const chartErrorMessage =
1103-
e.responseJSON && typeof e.responseJSON === 'object'
1104-
? e.responseJSON.detail
1105-
: typeof e.responseJSON === 'string'
1106-
? e.responseJSON
1107-
: e.message || e;
1102+
let chartErrorMessage: string | undefined;
1103+
if (e.responseJSON) {
1104+
if (typeof e.responseJSON === 'object' && e.responseJSON.detail) {
1105+
chartErrorMessage = e.responseJSON.detail;
1106+
}
1107+
if (typeof e.responseJSON === 'string') {
1108+
chartErrorMessage = e.responseJSON;
1109+
}
1110+
} else if (typeof e.message === 'string') {
1111+
chartErrorMessage = e.message;
1112+
} else {
1113+
chartErrorMessage = t('Something went wrong when rendering this chart.');
1114+
}
1115+
11081116
this.setState({
11091117
chartError: true,
11101118
chartErrorMessage,

0 commit comments

Comments
 (0)