FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GraphQL/reverse_engineering/helpers/mapError.js at develop · hackolade/GraphQL · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
hackolade
/
GraphQL
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
1
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
GraphQL
/
reverse_engineering
/
helpers
/
mapError.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (48 loc) · 1.24 KB
Breadcrumbs
GraphQL
/
reverse_engineering
/
helpers
/
mapError.js
Copy path
File metadata and controls
55 lines (48 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
*
@import
{REError} from "../../shared/types/types"
*/
const
{
InvalidSchemaError
}
=
require
(
'./parseSchema'
)
;
/**
* Maps different error types to a standardized error object structure for consistent error handling.
*
*
@param
{
unknown
} error - Any error object or primitive to be mapped
*
@returns
{
REError
} Standardized error object
*/
function
mapError
(
error
)
{
if
(
error
instanceof
InvalidSchemaError
)
{
return
{
title
:
error
.
title
,
message
:
error
.
message
,
type
:
error
.
type
||
'error'
,
stack
:
error
.
stack
,
}
;
}
if
(
error
instanceof
Error
)
{
return
{
title
:
error
.
name
||
'Error'
,
message
:
error
.
message
,
type
:
'error'
,
stack
:
error
.
stack
,
}
;
}
if
(
error
&&
typeof
error
===
'object'
)
{
const
errorMessage
=
'message'
in
error
?
String
(
error
.
message
)
:
'Unknown error occurred'
;
const
errorType
=
'type'
in
error
?
String
(
error
.
type
)
:
'error'
;
const
errorTitle
=
'title'
in
error
?
String
(
error
.
title
)
:
undefined
;
const
stackTrace
=
'stack'
in
error
?
String
(
error
.
stack
)
:
undefined
;
return
{
title
:
errorTitle
,
message
:
errorMessage
,
type
:
errorType
,
stack
:
stackTrace
,
}
;
}
return
{
title
:
'Error'
,
message
:
String
(
error
)
,
type
:
'error'
,
}
;
}
module
.
exports
=
{
mapError
,
}
;
Back
|
FazBrowse Home
|
New Git URL