@eggjs/onerror 4.0.0-beta.35 → 4.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +9 -5
- package/dist/agent.js +15 -13
- package/dist/app.d.ts +14 -10
- package/dist/app.js +110 -140
- package/dist/config/config.default.d.ts +27 -24
- package/dist/config/config.default.js +11 -9
- package/dist/index.d.ts +20 -16
- package/dist/index.js +24 -21
- package/dist/lib/error_view.d.ts +144 -140
- package/dist/lib/error_view.js +222 -239
- package/dist/lib/onerror_page.mustache.html +245 -245
- package/dist/lib/utils.d.ts +10 -6
- package/dist/lib/utils.js +17 -25
- package/dist/types.d.ts +8 -6
- package/dist/types.js +1 -2
- package/package.json +34 -39
|
@@ -4,251 +4,251 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<title></title>
|
|
6
6
|
<style>
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
7
|
+
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript&plugins=line-highlight+line-numbers+toolbar+show-language */
|
|
8
|
+
/**
|
|
9
|
+
* prism.js default theme for JavaScript, CSS and HTML
|
|
10
|
+
* Based on dabblet (http://dabblet.com)
|
|
11
|
+
* @author Lea Verou
|
|
12
|
+
*/
|
|
13
|
+
code[class*='language-'],
|
|
14
|
+
pre[class*='language-'] {
|
|
15
|
+
color: black;
|
|
16
|
+
background: none;
|
|
17
|
+
text-shadow: 0 1px white;
|
|
18
|
+
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
19
|
+
text-align: left;
|
|
20
|
+
white-space: pre;
|
|
21
|
+
word-spacing: normal;
|
|
22
|
+
word-break: normal;
|
|
23
|
+
word-wrap: normal;
|
|
24
|
+
line-height: 1.5;
|
|
25
|
+
-moz-tab-size: 4;
|
|
26
|
+
-o-tab-size: 4;
|
|
27
|
+
tab-size: 4;
|
|
28
|
+
-webkit-hyphens: none;
|
|
29
|
+
-moz-hyphens: none;
|
|
30
|
+
-ms-hyphens: none;
|
|
31
|
+
hyphens: none;
|
|
32
|
+
}
|
|
33
|
+
pre[class*='language-']::-moz-selection,
|
|
34
|
+
pre[class*='language-'] ::-moz-selection,
|
|
35
|
+
code[class*='language-']::-moz-selection,
|
|
36
|
+
code[class*='language-'] ::-moz-selection {
|
|
37
|
+
text-shadow: none;
|
|
38
|
+
background: #98d8b7;
|
|
39
|
+
}
|
|
40
|
+
pre[class*='language-']::selection,
|
|
41
|
+
pre[class*='language-'] ::selection,
|
|
42
|
+
code[class*='language-']::selection,
|
|
43
|
+
code[class*='language-'] ::selection {
|
|
44
|
+
text-shadow: none;
|
|
45
|
+
background: #98d8b7;
|
|
46
|
+
}
|
|
47
|
+
@media print {
|
|
48
|
+
code[class*='language-'],
|
|
49
|
+
pre[class*='language-'] {
|
|
50
|
+
text-shadow: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/* Code blocks */
|
|
54
|
+
pre[class*='language-'] {
|
|
55
|
+
padding: 1em;
|
|
56
|
+
margin: 0.5em 0;
|
|
57
|
+
overflow: auto;
|
|
58
|
+
}
|
|
59
|
+
:not(pre) > code[class*='language-'],
|
|
60
|
+
pre[class*='language-'] {
|
|
61
|
+
background: #f5f2f0;
|
|
62
|
+
}
|
|
63
|
+
/* Inline code */
|
|
64
|
+
:not(pre) > code[class*='language-'] {
|
|
65
|
+
padding: 0.1em;
|
|
66
|
+
border-radius: 0.3em;
|
|
67
|
+
white-space: normal;
|
|
68
|
+
}
|
|
69
|
+
.token.comment,
|
|
70
|
+
.token.prolog,
|
|
71
|
+
.token.doctype,
|
|
72
|
+
.token.cdata {
|
|
73
|
+
color: slategray;
|
|
74
|
+
}
|
|
75
|
+
.token.punctuation {
|
|
76
|
+
color: #999;
|
|
77
|
+
}
|
|
78
|
+
.namespace {
|
|
79
|
+
opacity: 0.7;
|
|
80
|
+
}
|
|
81
|
+
.token.property,
|
|
82
|
+
.token.tag,
|
|
83
|
+
.token.boolean,
|
|
84
|
+
.token.number,
|
|
85
|
+
.token.constant,
|
|
86
|
+
.token.symbol,
|
|
87
|
+
.token.deleted {
|
|
88
|
+
color: #905;
|
|
89
|
+
}
|
|
90
|
+
.token.selector,
|
|
91
|
+
.token.attr-name,
|
|
92
|
+
.token.string,
|
|
93
|
+
.token.char,
|
|
94
|
+
.token.builtin,
|
|
95
|
+
.token.inserted {
|
|
96
|
+
color: #690;
|
|
97
|
+
}
|
|
98
|
+
.token.operator,
|
|
99
|
+
.token.entity,
|
|
100
|
+
.token.url,
|
|
101
|
+
.language-css .token.string,
|
|
102
|
+
.style .token.string {
|
|
103
|
+
color: #a67f59;
|
|
104
|
+
background: hsla(0, 0%, 100%, 0.5);
|
|
105
|
+
}
|
|
106
|
+
.token.atrule,
|
|
107
|
+
.token.attr-value,
|
|
108
|
+
.token.keyword {
|
|
109
|
+
color: #07a;
|
|
110
|
+
}
|
|
111
|
+
.token.function {
|
|
112
|
+
color: #dd4a68;
|
|
113
|
+
}
|
|
114
|
+
.token.regex,
|
|
115
|
+
.token.important,
|
|
116
|
+
.token.variable {
|
|
117
|
+
color: #e90;
|
|
118
|
+
}
|
|
119
|
+
.token.important,
|
|
120
|
+
.token.bold {
|
|
121
|
+
font-weight: bold;
|
|
122
|
+
}
|
|
123
|
+
.token.italic {
|
|
124
|
+
font-style: italic;
|
|
125
|
+
}
|
|
126
|
+
.token.entity {
|
|
127
|
+
cursor: help;
|
|
128
|
+
}
|
|
129
|
+
pre[data-line] {
|
|
130
|
+
position: relative;
|
|
131
|
+
padding: 1em 0 1em 3em;
|
|
132
|
+
}
|
|
133
|
+
.line-highlight {
|
|
134
|
+
position: absolute;
|
|
135
|
+
left: 0;
|
|
136
|
+
right: 0;
|
|
137
|
+
padding: inherit 0;
|
|
138
|
+
margin-top: 1em; /* Same as .prism’s padding-top */
|
|
139
|
+
background: hsla(24, 20%, 50%, 0.08);
|
|
140
|
+
background: linear-gradient(to right, hsla(24, 20%, 50%, 0.1) 70%, hsla(24, 20%, 50%, 0));
|
|
141
|
+
pointer-events: none;
|
|
142
|
+
line-height: inherit;
|
|
143
|
+
white-space: pre;
|
|
144
|
+
}
|
|
145
|
+
.line-highlight:before,
|
|
146
|
+
.line-highlight[data-end]:after {
|
|
147
|
+
content: attr(data-start);
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: 0.4em;
|
|
150
|
+
left: 0.6em;
|
|
151
|
+
min-width: 1em;
|
|
152
|
+
padding: 0 0.5em;
|
|
153
|
+
background-color: hsla(24, 20%, 50%, 0.4);
|
|
154
|
+
color: hsl(24, 20%, 95%);
|
|
155
|
+
font: bold 65%/1.5 sans-serif;
|
|
156
|
+
text-align: center;
|
|
157
|
+
vertical-align: 0.3em;
|
|
158
|
+
border-radius: 999px;
|
|
159
|
+
text-shadow: none;
|
|
160
|
+
box-shadow: 0 1px white;
|
|
161
|
+
}
|
|
162
|
+
.line-highlight[data-end]:after {
|
|
163
|
+
content: attr(data-end);
|
|
164
|
+
top: auto;
|
|
165
|
+
bottom: 0.4em;
|
|
166
|
+
}
|
|
167
|
+
pre.line-numbers {
|
|
168
|
+
position: relative;
|
|
169
|
+
padding-left: 3.8em;
|
|
170
|
+
counter-reset: linenumber;
|
|
171
|
+
}
|
|
172
|
+
pre.line-numbers > code {
|
|
173
|
+
position: relative;
|
|
174
|
+
}
|
|
175
|
+
.line-numbers .line-numbers-rows {
|
|
176
|
+
position: absolute;
|
|
177
|
+
pointer-events: none;
|
|
178
|
+
top: 0;
|
|
179
|
+
font-size: 100%;
|
|
180
|
+
left: -3.8em;
|
|
181
|
+
width: 3em; /* works for line-numbers below 1000 lines */
|
|
182
|
+
letter-spacing: -1px;
|
|
183
|
+
border-right: 1px solid #999;
|
|
184
|
+
-webkit-user-select: none;
|
|
185
|
+
-moz-user-select: none;
|
|
186
|
+
-ms-user-select: none;
|
|
187
|
+
user-select: none;
|
|
188
|
+
}
|
|
189
|
+
.line-numbers-rows > span {
|
|
190
|
+
pointer-events: none;
|
|
191
|
+
display: block;
|
|
192
|
+
counter-increment: linenumber;
|
|
193
|
+
}
|
|
194
|
+
.line-numbers-rows > span:before {
|
|
195
|
+
content: counter(linenumber);
|
|
196
|
+
color: #999;
|
|
197
|
+
display: block;
|
|
198
|
+
padding-right: 0.8em;
|
|
199
|
+
text-align: right;
|
|
200
|
+
}
|
|
201
|
+
pre.code-toolbar {
|
|
202
|
+
position: relative;
|
|
203
|
+
}
|
|
204
|
+
pre.code-toolbar > .toolbar {
|
|
205
|
+
position: absolute;
|
|
206
|
+
top: 0.3em;
|
|
207
|
+
right: 0.2em;
|
|
208
|
+
transition: opacity 0.3s ease-in-out;
|
|
209
|
+
opacity: 0;
|
|
210
|
+
}
|
|
211
|
+
pre.code-toolbar:hover > .toolbar {
|
|
212
|
+
opacity: 1;
|
|
213
|
+
}
|
|
214
|
+
pre.code-toolbar > .toolbar .toolbar-item {
|
|
215
|
+
display: inline-block;
|
|
216
|
+
}
|
|
217
|
+
pre.code-toolbar > .toolbar a {
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
}
|
|
220
|
+
pre.code-toolbar > .toolbar button {
|
|
221
|
+
background: none;
|
|
222
|
+
border: 0;
|
|
223
|
+
color: inherit;
|
|
224
|
+
font: inherit;
|
|
225
|
+
line-height: normal;
|
|
226
|
+
overflow: visible;
|
|
227
|
+
padding: 0;
|
|
228
|
+
-webkit-user-select: none; /* for button */
|
|
229
|
+
-moz-user-select: none;
|
|
230
|
+
-ms-user-select: none;
|
|
231
|
+
}
|
|
232
|
+
pre.code-toolbar > .toolbar a,
|
|
233
|
+
pre.code-toolbar > .toolbar button,
|
|
234
|
+
pre.code-toolbar > .toolbar span {
|
|
235
|
+
color: #bbb;
|
|
236
|
+
font-size: 0.8em;
|
|
237
|
+
padding: 0 0.5em;
|
|
238
|
+
background: #f5f2f0;
|
|
239
|
+
background: rgba(224, 224, 224, 0.2);
|
|
240
|
+
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2);
|
|
241
|
+
border-radius: 0.5em;
|
|
242
|
+
}
|
|
243
|
+
pre.code-toolbar > .toolbar a:hover,
|
|
244
|
+
pre.code-toolbar > .toolbar a:focus,
|
|
245
|
+
pre.code-toolbar > .toolbar button:hover,
|
|
246
|
+
pre.code-toolbar > .toolbar button:focus,
|
|
247
|
+
pre.code-toolbar > .toolbar span:hover,
|
|
248
|
+
pre.code-toolbar > .toolbar span:focus {
|
|
249
|
+
color: inherit;
|
|
250
|
+
text-decoration: none;
|
|
251
|
+
}
|
|
252
252
|
</style>
|
|
253
253
|
|
|
254
254
|
<style>
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { OnerrorError } from "koa-onerror";
|
|
2
|
+
import { Application, Context } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/utils.d.ts
|
|
5
|
+
declare function detectErrorMessage(ctx: Context, err: OnerrorError): string;
|
|
6
|
+
declare function detectStatus(err: OnerrorError): number;
|
|
7
|
+
declare function accepts(ctx: Context): "json" | "js" | "html";
|
|
8
|
+
declare function isProd(app: Application): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { accepts, detectErrorMessage, detectStatus, isProd };
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ctx.request.is('application/json', 'application/vnd.api+json', 'application/csp-report')) {
|
|
6
|
-
return 'Problems parsing JSON';
|
|
7
|
-
}
|
|
8
|
-
return err.message;
|
|
1
|
+
//#region src/lib/utils.ts
|
|
2
|
+
function detectErrorMessage(ctx, err) {
|
|
3
|
+
if (err.status === 400 && err.name === "SyntaxError" && ctx.request.is("application/json", "application/vnd.api+json", "application/csp-report")) return "Problems parsing JSON";
|
|
4
|
+
return err.message;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// invalid status consider as 500, like urllib will return -1 status
|
|
15
|
-
status = 500;
|
|
16
|
-
}
|
|
17
|
-
return status;
|
|
6
|
+
function detectStatus(err) {
|
|
7
|
+
let status = err.status || 500;
|
|
8
|
+
if (status < 200) status = 500;
|
|
9
|
+
return status;
|
|
18
10
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return 'js';
|
|
24
|
-
return 'html';
|
|
11
|
+
function accepts(ctx) {
|
|
12
|
+
if (ctx.acceptJSON) return "json";
|
|
13
|
+
if (ctx.acceptJSONP) return "js";
|
|
14
|
+
return "html";
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
function isProd(app) {
|
|
17
|
+
return app.config.env !== "local" && app.config.env !== "unittest";
|
|
28
18
|
}
|
|
29
|
-
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { accepts, detectErrorMessage, detectStatus, isProd };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { OnerrorConfig } from "./config/config.default.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
declare module "egg" {
|
|
5
|
+
interface EggAppConfig {
|
|
6
|
+
onerror: OnerrorConfig;
|
|
7
|
+
}
|
|
8
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
1
|
+
export { };
|