Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
8b1e25b5
Commit
8b1e25b5
authored
Mar 05, 2019
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: show string errors. Fixes #15782
parent
989147a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletions
+56
-1
public/app/core/utils/errors.test.ts
+55
-0
public/app/core/utils/errors.ts
+1
-1
No files found.
public/app/core/utils/errors.test.ts
0 → 100644
View file @
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"}'
);
});
});
});
public/app/core/utils/errors.ts
View file @
8b1e25b5
...
...
@@ -13,5 +13,5 @@ export function getMessageFromError(err: any): string | null {
}
}
return
null
;
return
err
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment