From 8bb4369ba52e0327bdf9aea6ab449d484be88f82 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Tue, 14 Feb 2023 18:19:26 +0800 Subject: [PATCH] ignore errors thrown from deferred calls --- src/index.js | 5 +++++ src/runtime.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/index.js b/src/index.js index f2fd60e..3afc6fb 100644 --- a/src/index.js +++ b/src/index.js @@ -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)) diff --git a/src/runtime.js b/src/runtime.js index 979ae28..a656fd1 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -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 {