CloudWatch Logs: Fix crash when no region is configured (#37639) (#37646)

(cherry picked from commit e9c032f10f)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-08-06 22:16:40 +02:00
committed by GitHub
co-authored by Andrej Ocenas
parent 302c542aba
commit 2ee831969d
2 changed files with 12 additions and 1 deletions
@@ -119,7 +119,15 @@ export class CloudWatchLogsQueryField extends React.PureComponent<CloudWatchLogs
label: logGroup,
}));
} catch (err) {
dispatch(notifyApp(createErrorNotification(err)));
let errMessage = 'unknown error';
if (typeof err !== 'string') {
try {
errMessage = JSON.stringify(err);
} catch (e) {}
} else {
errMessage = err;
}
dispatch(notifyApp(createErrorNotification(errMessage)));
return [];
}
};
@@ -660,6 +660,9 @@ export class CloudWatchDatasource extends DataSourceWithBackend<CloudWatchQuery,
catchError((err) => {
if (err.data?.error) {
throw err.data.error;
} else if (err.data?.message) {
// In PROD we do not supply .error
throw err.data.message;
}
throw err;