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

This commit is contained in:
Andrej Ocenas
2021-08-06 15:47:27 +02:00
committed by GitHub
parent f83cd401e5
commit e9c032f10f
2 changed files with 12 additions and 1 deletions

View File

@ -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 [];
}
};

View File

@ -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;