Skip to content

Commit

Permalink
增加对 jsb["onError"] 的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
1226085293 committed Jun 26, 2024
1 parent 60e288b commit 3ae10c4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions extensions/MKFramework/assets/mk-framework/@framework/mk_logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,22 @@ class mk_logger extends mk_instance_base {
} else if (cc.sys.isNative) {
let old_handler: any;

if (window["__errorHandler"]) {
old_handler = window["__errorHandler"];
}

window["__errorHandler"] = function (...args_as: any[]) {
upload_f(...args_as);
if (old_handler) {
old_handler(...args_as);
if (window["jsb"]) {
jsb["onError"]((...args_as: any[]) => {
upload_f(...args_as);
});
} else {
if (window["__errorHandler"]) {
old_handler = window["__errorHandler"];
}
};

window["__errorHandler"] = function (...args_as: any[]) {
upload_f(...args_as);
if (old_handler) {
old_handler(...args_as);
}
};
}
}
}
}
Expand Down

0 comments on commit 3ae10c4

Please sign in to comment.