ignore errors thrown from deferred calls

This commit is contained in:
Dmitry Vasilev
2023-02-14 18:19:26 +08:00
parent e7d4fce372
commit 8bb4369ba5
2 changed files with 10 additions and 0 deletions

View File

@@ -12,6 +12,9 @@ fib(6)`
const set_error_handler = (w, with_unhandled_rejection = true) => {
// TODO err.message
w.onerror = (msg, src, lineNum, colNum, err) => {
if(err?.__ignore) {
return
}
ui.set_status(msg)
}
if(with_unhandled_rejection) {
@@ -48,6 +51,8 @@ const open_run_iframe = (state, onload) => {
// Open another browser window so user can interact with application
// TODO test in another browsers
export const open_run_window = state => {
// TODO set_error_handler? Or we dont need to set_error_handler for child
// window because error is always caught by parent window handler?
globalThis.run_window.close()
const next_window = globalThis.run_window = open(get_html_url(state))

View File

@@ -326,6 +326,11 @@ const __trace = (cxt, fn, name, argscount, __location, get_closure) => {
ok = false
error = _error
set_record_call(cxt)
if(cxt.is_recording_deferred_calls && is_toplevel_call_copy) {
if(error instanceof cxt.window.Error) {
error.__ignore = true
}
}
throw error
} finally {