FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
popcode/src/util/normalizeError.js at master · popcodeorg/popcode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
popcodeorg
/
popcode
Public
Notifications
You must be signed in to change notification settings
Fork
143
Star
191
Code
Issues
144
Pull requests
20
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
popcode
/
src
/
util
/
normalizeError.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
122 lines (101 loc) · 2.75 KB
Breadcrumbs
popcode
/
src
/
util
/
normalizeError.js
Copy path
File metadata and controls
122 lines (101 loc) · 2.75 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import
i18next
from
'i18next'
;
import
assign
from
'lodash-es/assign'
;
import
get
from
'lodash-es/get'
;
import
isEmpty
from
'lodash-es/isEmpty'
;
import
keys
from
'lodash-es/keys'
;
import
bowser
from
'../services/bowser'
;
const
normalizers
=
{
Chrome
:
{
TypeError
:
message
=>
{
let
match
;
match
=
/
^
(
\w
+
)
i
s
n
o
t
a
f
u
n
c
t
i
o
n
$
/
u
.
exec
(
message
)
;
if
(
match
)
{
return
{
type
:
'not-a-function'
,
params
:
{
name
:
match
[
1
]
}
}
;
}
match
=
/
^
C
a
n
n
o
t
(
r
e
a
d
|
s
e
t
)
p
r
o
p
e
r
t
y
'
(
.
+
)
'
o
f
(
n
u
l
l
|
u
n
d
e
f
i
n
e
d
)
$
/
u
.
exec
(
message
,
)
;
if
(
match
)
{
return
{
type
:
`
${
match
[
1
]
}
-property-of-
${
match
[
3
]
}
`
,
params
:
{
property
:
match
[
2
]
}
,
}
;
}
return
null
;
}
,
}
,
Safari
:
{
TypeError
:
message
=>
{
let
match
;
match
=
/
^
(
\w
+
)
i
s
n
o
t
a
f
u
n
c
t
i
o
n
.
\(
I
n
'
\w
+
\(
\)
'
,
'
\w
+
'
i
s
(
\w
+
|
a
n
i
n
s
t
a
n
c
e
o
f
(
\w
+
)
)
\)
$
/
u
.
exec
(
message
,
)
;
if
(
match
)
{
if
(
match
[
3
]
)
{
return
{
type
:
'not-a-function'
,
params
:
{
name
:
match
[
1
]
,
type
:
match
[
3
]
}
,
}
;
}
if
(
match
[
2
]
===
'undefined'
||
match
[
2
]
===
'null'
)
{
return
{
type
:
`
${
match
[
2
]
}
-not-a-function`
,
params
:
{
name
:
match
[
1
]
}
,
}
;
}
return
{
type
:
'not-a-function'
,
params
:
{
name
:
match
[
1
]
,
value
:
match
[
2
]
}
,
}
;
}
match
=
/
^
(
n
u
l
l
|
u
n
d
e
f
i
n
e
d
)
i
s
n
o
t
a
n
o
b
j
e
c
t
\(
.
*
\)
$
/
u
.
exec
(
message
)
;
if
(
match
)
{
return
{
type
:
`access-property-of-
${
match
[
1
]
}
`
}
;
}
return
null
;
}
,
}
,
Firefox
:
{
TypeError
:
message
=>
{
let
match
;
match
=
/
^
(
\w
+
)
i
s
n
o
t
a
f
u
n
c
t
i
o
n
$
/
u
.
exec
(
message
)
;
if
(
match
)
{
return
{
type
:
'not-a-function'
,
params
:
{
name
:
match
[
1
]
}
}
;
}
match
=
/
^
(
[
\w
.
]
+
)
i
s
(
n
u
l
l
|
u
n
d
e
f
i
n
e
d
)
$
/
u
.
exec
(
message
)
;
if
(
match
)
{
return
{
type
:
`access-property-of-
${
match
[
2
]
}
`
,
params
:
{
name
:
match
[
1
]
}
,
}
;
}
return
null
;
}
,
}
,
}
;
function
attachMessage
(
normalizedError
)
{
let
context
;
if
(
!
isEmpty
(
normalizedError
.
params
)
)
{
context
=
`with-
${
keys
(
normalizedError
.
params
)
.
sort
(
)
.
join
(
'-'
)
}
`
;
}
return
assign
(
normalizedError
,
{
message
:
i18next
.
t
(
`errors.javascriptRuntime.
${
normalizedError
.
type
}
`
,
assign
(
{
context
}
,
normalizedError
.
params
)
,
)
,
}
)
;
}
function
normalizeError
(
error
)
{
const
normalizer
=
get
(
normalizers
,
[
bowser
.
getBrowserName
(
)
,
error
.
name
]
)
;
if
(
normalizer
!==
undefined
)
{
const
normalizedError
=
normalizer
(
error
.
message
)
;
if
(
normalizedError
!==
null
)
{
return
attachMessage
(
normalizedError
)
;
}
}
return
{
type
:
'unknown'
,
message
:
error
.
message
,
}
;
}
export
default
normalizeError
;
Back
|
FazBrowse Home
|
New Git URL