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