diff --git a/noname/init/index.js b/noname/init/index.js index 13f148ef7..0a37ea546 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -864,7 +864,13 @@ async function setOnError() { } //解析parsex里的content fun内容(通常是技能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))) { + else if (err && err.stack && ['at Object.eval [as content]', 'at Proxy.content'].some(str =>{ + let stackSplit1 = err.stack.split('\n')[1]; + if(stackSplit1){ + return stackSplit1.trim().startsWith(str); + } + return false; + })) { 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 a5120a367..e76317535 100644 --- a/noname/util/struct/promise-error-handler/chrome.js +++ b/noname/util/struct/promise-error-handler/chrome.js @@ -129,12 +129,16 @@ export class ChromePromiseErrorHandler { } // 反之我们只能不考虑报错文件信息,直接调用onerror else { - // @ts-ignore - 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); + try{ + // @ts-ignore + 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); + }catch(e){ + window.onerror(error.message,'',0,0, error); + } } } /*