mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
bad048b7ba
* Performance: Standardize lodash imports to use destructured members Changes lodash imports of the form `import x from 'lodash/x'` to `import { x } from 'lodash'` to reduce bundle size. * Remove unnecessary _ import from Graph component * Enforce lodash import style * Fix remaining lodash imports
18 lines
447 B
TypeScript
18 lines
447 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 as string;
|
|
}
|