@eggjs/onerror 4.0.0-beta.19 → 4.0.0-beta.21
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 +5 -9
- package/dist/agent.js +13 -15
- package/dist/app.d.ts +10 -14
- package/dist/app.js +140 -110
- package/dist/config/config.default.d.ts +24 -27
- package/dist/config/config.default.js +9 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/error_view.d.ts +149 -153
- package/dist/lib/error_view.js +239 -222
- package/dist/lib/utils.d.ts +6 -10
- package/dist/lib/utils.js +25 -17
- package/dist/types.d.ts +5 -7
- package/dist/types.js +2 -1
- package/package.json +4 -4
package/dist/lib/error_view.d.ts
CHANGED
|
@@ -1,158 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Context } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
line: string;
|
|
9
|
-
post: string[];
|
|
1
|
+
import { type StackFrame } from 'stack-trace';
|
|
2
|
+
import type { OnerrorError } from 'koa-onerror';
|
|
3
|
+
import type { Context } from 'egg';
|
|
4
|
+
export interface FrameSource {
|
|
5
|
+
pre: string[];
|
|
6
|
+
line: string;
|
|
7
|
+
post: string[];
|
|
10
8
|
}
|
|
11
|
-
interface Frame extends StackFrame {
|
|
12
|
-
|
|
9
|
+
export interface Frame extends StackFrame {
|
|
10
|
+
context?: FrameSource;
|
|
13
11
|
}
|
|
14
|
-
declare class ErrorView {
|
|
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
|
-
start: number;
|
|
84
|
-
pre: string;
|
|
85
|
-
line: string;
|
|
86
|
-
post: string;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* get frame classes, let view identify the frame
|
|
90
|
-
*
|
|
91
|
-
* @param {any} frame - current frame
|
|
92
|
-
* @param {any} index - current index
|
|
93
|
-
*/
|
|
94
|
-
getFrameClasses(frame: Frame, index: number): string;
|
|
95
|
-
/**
|
|
96
|
-
* serialize frame and return meaningful data
|
|
97
|
-
*
|
|
98
|
-
* @param {Object} frame - current frame
|
|
99
|
-
*/
|
|
100
|
-
serializeFrame(frame: Frame): {
|
|
101
|
-
extname: string;
|
|
102
|
-
file: string;
|
|
103
|
-
method: string;
|
|
104
|
-
line: number;
|
|
105
|
-
column: number;
|
|
106
|
-
context: {
|
|
107
|
-
start?: undefined;
|
|
108
|
-
pre?: undefined;
|
|
109
|
-
line?: undefined;
|
|
110
|
-
post?: undefined;
|
|
12
|
+
export declare class ErrorView {
|
|
13
|
+
ctx: Context;
|
|
14
|
+
error: OnerrorError;
|
|
15
|
+
request: Context['request'];
|
|
16
|
+
app: Context['app'];
|
|
17
|
+
assets: Map<string, string>;
|
|
18
|
+
viewTemplate: string;
|
|
19
|
+
codeContext: number;
|
|
20
|
+
_filterHeaders: string[];
|
|
21
|
+
constructor(ctx: Context, error: OnerrorError, template: string);
|
|
22
|
+
/**
|
|
23
|
+
* get html error page
|
|
24
|
+
*
|
|
25
|
+
* @return {String} html page
|
|
26
|
+
*/
|
|
27
|
+
toHTML(): string;
|
|
28
|
+
/**
|
|
29
|
+
* compile view
|
|
30
|
+
*
|
|
31
|
+
* @param {String} tpl - template
|
|
32
|
+
* @param {Object} locals - data used by template
|
|
33
|
+
*/
|
|
34
|
+
compileView(tpl: string, locals: Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* check if the frame is node native file.
|
|
37
|
+
*
|
|
38
|
+
* @param {Frame} frame - current frame
|
|
39
|
+
*/
|
|
40
|
+
isNode(frame: Frame): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* check if the frame is app modules.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} frame - current frame
|
|
45
|
+
*/
|
|
46
|
+
isApp(frame: Frame): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* cache file asserts
|
|
49
|
+
*
|
|
50
|
+
* @param {String} key - assert key
|
|
51
|
+
* @param {String} value - assert content
|
|
52
|
+
*/
|
|
53
|
+
setAssets(key: string, value: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* get cache file asserts
|
|
56
|
+
*
|
|
57
|
+
* @param {String} key - assert key
|
|
58
|
+
*/
|
|
59
|
+
getAssets(key: string): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* get frame source
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} frame - current frame
|
|
64
|
+
*/
|
|
65
|
+
getFrameSource(frame: StackFrame): FrameSource;
|
|
66
|
+
/**
|
|
67
|
+
* parse error and return frame stack
|
|
68
|
+
*/
|
|
69
|
+
parseError(): Frame[];
|
|
70
|
+
/**
|
|
71
|
+
* get stack context
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} frame - current frame
|
|
74
|
+
*/
|
|
75
|
+
getContext(frame: Frame): {
|
|
76
|
+
start?: undefined;
|
|
77
|
+
pre?: undefined;
|
|
78
|
+
line?: undefined;
|
|
79
|
+
post?: undefined;
|
|
111
80
|
} | {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
81
|
+
start: number;
|
|
82
|
+
pre: string;
|
|
83
|
+
line: string;
|
|
84
|
+
post: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* get frame classes, let view identify the frame
|
|
88
|
+
*
|
|
89
|
+
* @param {any} frame - current frame
|
|
90
|
+
* @param {any} index - current index
|
|
91
|
+
*/
|
|
92
|
+
getFrameClasses(frame: Frame, index: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* serialize frame and return meaningful data
|
|
95
|
+
*
|
|
96
|
+
* @param {Object} frame - current frame
|
|
97
|
+
*/
|
|
98
|
+
serializeFrame(frame: Frame): {
|
|
99
|
+
extname: string;
|
|
100
|
+
file: string;
|
|
101
|
+
method: string;
|
|
102
|
+
line: number;
|
|
103
|
+
column: number;
|
|
104
|
+
context: {
|
|
105
|
+
start?: undefined;
|
|
106
|
+
pre?: undefined;
|
|
107
|
+
line?: undefined;
|
|
108
|
+
post?: undefined;
|
|
109
|
+
} | {
|
|
110
|
+
start: number;
|
|
111
|
+
pre: string;
|
|
112
|
+
line: string;
|
|
113
|
+
post: string;
|
|
114
|
+
};
|
|
115
|
+
classes: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* serialize base data
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} stack - frame stack
|
|
121
|
+
* @param {Function} frameFormatter - frame formatter function
|
|
122
|
+
*/
|
|
123
|
+
serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
|
|
124
|
+
code: any;
|
|
125
|
+
message: string;
|
|
126
|
+
name: string;
|
|
127
|
+
status: number;
|
|
128
|
+
frames: any[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* serialize request object
|
|
132
|
+
*/
|
|
133
|
+
serializeRequest(): {
|
|
134
|
+
url: string;
|
|
135
|
+
httpVersion: string;
|
|
136
|
+
method: string;
|
|
137
|
+
connection: string | undefined;
|
|
138
|
+
headers: {
|
|
139
|
+
key: string;
|
|
140
|
+
value: string | string[] | undefined;
|
|
141
|
+
}[];
|
|
142
|
+
cookies: {
|
|
143
|
+
key: string;
|
|
144
|
+
value: string | undefined;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* serialize app info object
|
|
149
|
+
*/
|
|
150
|
+
serializeAppInfo(): {
|
|
151
|
+
baseDir: string;
|
|
152
|
+
config: string;
|
|
116
153
|
};
|
|
117
|
-
classes: string;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* serialize base data
|
|
121
|
-
*
|
|
122
|
-
* @param {Object} stack - frame stack
|
|
123
|
-
* @param {Function} frameFormatter - frame formatter function
|
|
124
|
-
*/
|
|
125
|
-
serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
|
|
126
|
-
code: any;
|
|
127
|
-
message: string;
|
|
128
|
-
name: string;
|
|
129
|
-
status: number;
|
|
130
|
-
frames: any[];
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* serialize request object
|
|
134
|
-
*/
|
|
135
|
-
serializeRequest(): {
|
|
136
|
-
url: string;
|
|
137
|
-
httpVersion: string;
|
|
138
|
-
method: string;
|
|
139
|
-
connection: string | undefined;
|
|
140
|
-
headers: {
|
|
141
|
-
key: string;
|
|
142
|
-
value: string | string[] | undefined;
|
|
143
|
-
}[];
|
|
144
|
-
cookies: {
|
|
145
|
-
key: string;
|
|
146
|
-
value: string | undefined;
|
|
147
|
-
}[];
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* serialize app info object
|
|
151
|
-
*/
|
|
152
|
-
serializeAppInfo(): {
|
|
153
|
-
baseDir: string;
|
|
154
|
-
config: string;
|
|
155
|
-
};
|
|
156
154
|
}
|
|
157
|
-
//#endregion
|
|
158
|
-
export { ErrorView, Frame, FrameSource };
|