forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
447 B
17 lines
447 B
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 as string;
|
|
}
|
|
|