diff --git a/noname/init/index.js b/noname/init/index.js index ddb33575a..02835a5f8 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -861,7 +861,8 @@ async function setOnError() { } } //解析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; if (typeof codes == 'function') { const lines = codes.toString().split("\n"); diff --git a/noname/util/struct/promise-error-handler/chrome.js b/noname/util/struct/promise-error-handler/chrome.js index 79b65ac4d..a5120a367 100644 --- a/noname/util/struct/promise-error-handler/chrome.js +++ b/noname/util/struct/promise-error-handler/chrome.js @@ -98,12 +98,12 @@ export class ChromePromiseErrorHandler { let fileName = void 0; /** - * @type {string | undefined} + * @type {number | undefined} */ let line = void 0; /** - * @type {string | undefined} + * @type {number | undefined} */ let column = void 0; @@ -119,8 +119,8 @@ export class ChromePromiseErrorHandler { const locationParts = extractLocation(location ? location[1] : formatedLine); fileName = ['eval', ''].includes(locationParts[0]) ? void 0 : locationParts[0]; - line = locationParts[1]; - column = locationParts[2]; + line = Number(locationParts[1]); + column = Number(locationParts[2]); break; } @@ -130,7 +130,11 @@ export class ChromePromiseErrorHandler { // 反之我们只能不考虑报错文件信息,直接调用onerror else { // @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); } } /*