Merge pull request #811 from nonameShijian/PR-Branch

修复技能报错不提示技能代码的bug
This commit is contained in:
Spmario233 2024-01-19 00:51:22 +08:00 committed by GitHub
commit 7d2f5a8b38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -861,7 +861,8 @@ async function setOnError() {
} }
} }
//解析parsex里的content fun内容(通常是技能content) //解析parsex里的content fun内容(通常是技能content)
else if (err && err.stack && err.stack.split('\n')[1].trim().startsWith('at Object.eval [as content]')) { // @ts-ignore
else if (err && err.stack && ['at Object.eval [as content]', 'at Proxy.content'].some(str => err.stack.split('\n')[1].trim().startsWith(str))) {
const codes = _status.event.content; const codes = _status.event.content;
if (typeof codes == 'function') { if (typeof codes == 'function') {
const lines = codes.toString().split("\n"); const lines = codes.toString().split("\n");

View File

@ -98,12 +98,12 @@ export class ChromePromiseErrorHandler {
let fileName = void 0; let fileName = void 0;
/** /**
* @type {string | undefined} * @type {number | undefined}
*/ */
let line = void 0; let line = void 0;
/** /**
* @type {string | undefined} * @type {number | undefined}
*/ */
let column = void 0; let column = void 0;
@ -119,8 +119,8 @@ export class ChromePromiseErrorHandler {
const locationParts = extractLocation(location ? location[1] : formatedLine); const locationParts = extractLocation(location ? location[1] : formatedLine);
fileName = ['eval', '<anonymous>'].includes(locationParts[0]) ? void 0 : locationParts[0]; fileName = ['eval', '<anonymous>'].includes(locationParts[0]) ? void 0 : locationParts[0];
line = locationParts[1]; line = Number(locationParts[1]);
column = locationParts[2]; column = Number(locationParts[2]);
break; break;
} }
@ -130,7 +130,11 @@ export class ChromePromiseErrorHandler {
// 反之我们只能不考虑报错文件信息直接调用onerror // 反之我们只能不考虑报错文件信息直接调用onerror
else { else {
// @ts-ignore // @ts-ignore
window.onerror(error.message, void 0, void 0, void 0, error); let [_, src = void 0, line = void 0, column = void 0] = /at\s+.*\s+\((.*):(\d*):(\d*)\)/i.exec(error.stack.split('\n')[1])
if (typeof line == 'string') line = Number(line);
if (typeof column == 'string') column = Number(column);
// @ts-ignore
window.onerror(error.message, src, line, column, error);
} }
} }
/* /*