grafana/public/app/core/utils/errors.ts
Lukas Siatka ee12f5e742
Strict null fixes: updates return type of getMessageFromError, fixes QueryOperationAction props (#24690)
* Chore: updates getMessageFromError return type

* Chore: updates the position of incorrectly placed bang operator

* Chore: updates typing on dropdown typeahead directive

* Chore: updates QueryOperationAction props to require title

* Revert "Chore: updates QueryOperationAction props to require title"
2020-05-14 17:08:52 +02:00

18 lines
438 B
TypeScript

import _ from 'lodash';
export function getMessageFromError(err: string | (Error & { data?: any; statusText?: string })): string {
if (err && !_.isString(err)) {
if (err.message) {
return err.message;
} else if (err.data && err.data.message) {
return err.data.message;
} else if (err.statusText) {
return err.statusText;
} else {
return JSON.stringify(err);
}
}
return err as string;
}