Commit 1711622e by Torkel Ödegaard Committed by GitHub

Merge pull request #15784 from grafana/15782-error-fix

In error popup, fixes bug so that string errors are shown again. Fixes #15782
parents 48570c62 8b1e25b5
import { getMessageFromError } from 'app/core/utils/errors';
describe('errors functions', () => {
let message;
describe('when getMessageFromError gets an error string', () => {
beforeEach(() => {
message = getMessageFromError('error string');
});
it('should return the string', () => {
expect(message).toBe('error string');
});
});
describe('when getMessageFromError gets an error object with message field', () => {
beforeEach(() => {
message = getMessageFromError({ message: 'error string' });
});
it('should return the message text', () => {
expect(message).toBe('error string');
});
});
describe('when getMessageFromError gets an error object with data.message field', () => {
beforeEach(() => {
message = getMessageFromError({ data: { message: 'error string' } });
});
it('should return the message text', () => {
expect(message).toBe('error string');
});
});
describe('when getMessageFromError gets an error object with statusText field', () => {
beforeEach(() => {
message = getMessageFromError({ statusText: 'error string' });
});
it('should return the statusText text', () => {
expect(message).toBe('error string');
});
});
describe('when getMessageFromError gets an error object', () => {
beforeEach(() => {
message = getMessageFromError({ customError: 'error string' });
});
it('should return the stringified error', () => {
expect(message).toBe('{"customError":"error string"}');
});
});
});
......@@ -13,5 +13,5 @@ export function getMessageFromError(err: any): string | null {
}
}
return null;
return err;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment