@lark-apaas/fullstack-rspack-preset 1.0.8-alpha.log.6 → 1.0.8
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/lib/overlay/index.js +11 -12
- package/package.json +1 -1
package/lib/overlay/index.js
CHANGED
|
@@ -157,9 +157,14 @@ function sendPostMessage(message, targetOrigin) {
|
|
|
157
157
|
/**
|
|
158
158
|
* 上报错误信息
|
|
159
159
|
* @param {(string | Error)[]} messages 日志信息
|
|
160
|
-
* @param {
|
|
160
|
+
* @param {'compileError' | 'runtimeError'} mode 日志模式
|
|
161
161
|
*/
|
|
162
|
-
function logError(messages,
|
|
162
|
+
function logError(messages, mode) {
|
|
163
|
+
const logMeta = {
|
|
164
|
+
noStacktrace: mode === 'compileError',
|
|
165
|
+
stacktrace: mode === 'compileError' ? [] : undefined,
|
|
166
|
+
type: mode === 'compileError' ? 'compile-error' : 'uncaught-render-error',
|
|
167
|
+
};
|
|
163
168
|
try {
|
|
164
169
|
// 优先使用暴露的 __RUNTIME_LOGGER__ 上报错误
|
|
165
170
|
// 运行时错误出现时,window已经挂载
|
|
@@ -167,10 +172,7 @@ function logError(messages, noStacktrace = false) {
|
|
|
167
172
|
window.__RUNTIME_LOGGER__.get().log({
|
|
168
173
|
level: 'error',
|
|
169
174
|
args: messages,
|
|
170
|
-
meta:
|
|
171
|
-
noStacktrace,
|
|
172
|
-
stacktrace: noStacktrace ? [] : undefined,
|
|
173
|
-
}
|
|
175
|
+
meta: logMeta,
|
|
174
176
|
});
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
@@ -193,10 +195,7 @@ function logError(messages, noStacktrace = false) {
|
|
|
193
195
|
type: 'typedLogV2',
|
|
194
196
|
level: 'error',
|
|
195
197
|
args: parts,
|
|
196
|
-
meta:
|
|
197
|
-
noStacktrace,
|
|
198
|
-
stacktrace: noStacktrace ? [] : undefined,
|
|
199
|
-
}
|
|
198
|
+
meta: logMeta,
|
|
200
199
|
};
|
|
201
200
|
sendPostMessage({ type: 'SELECTED_LOG', payload: JSON.stringify(logJSON) });
|
|
202
201
|
}
|
|
@@ -228,13 +227,13 @@ function render() {
|
|
|
228
227
|
if (currentCompileErrorMessage) {
|
|
229
228
|
currentMode = 'compileError';
|
|
230
229
|
// 发送编译错误
|
|
231
|
-
logError(['Compile Error', currentCompileErrorMessage],
|
|
230
|
+
logError(['Compile Error', currentCompileErrorMessage], currentMode);
|
|
232
231
|
ErrorContainer(rootDocument, root, '编译出错');
|
|
233
232
|
}
|
|
234
233
|
else if (currentRuntimeErrors.length) {
|
|
235
234
|
currentMode = 'runtimeError';
|
|
236
235
|
// 发送运行错误
|
|
237
|
-
logError(['Uncaught Render Error', ...currentRuntimeErrors]);
|
|
236
|
+
logError(['Uncaught Render Error', ...currentRuntimeErrors], currentMode);
|
|
238
237
|
// 叠加全部报错,将报错信息发送到妙搭
|
|
239
238
|
ErrorContainer(rootDocument, root, '页面出错了');
|
|
240
239
|
}
|