mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* more friday any/type assertion improvements * Apply suggestions from code review Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> * Update public/app/angular/promiseToDigest.test.ts Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
18 lines
437 B
TypeScript
18 lines
437 B
TypeScript
import { isString } 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;
|
|
}
|