Merge pull request #828 from universe-st/PR-Branch-fixerr

报错增加兜底
This commit is contained in:
Spmario233 2024-01-20 22:55:01 +08:00 committed by GitHub
commit 5c2e0c7553
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -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");

View File

@ -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);
}
}
}
/*