Open XadillaX opened 1 year ago
Can you give some examples of exceptions that do not come from Promise
?
function test() {
throw new Error('hello');
}
test();
maybe use something like
addEventListener('error', fn)
That would imply, in a browser, an "error" event on the document, I think. Do browsers have an event for this?
That would imply, in a browser, an "error" event on the document, I think. Do browsers have an event for this?
https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event
ah ok, so then it’s already an event on the global - that seems like something that should come for free with event emitters?
ah ok, so then it’s already an event on the global - that seems like something that should come for free with event emitters?
I think yes.
Not only for this event. I think we shoud collect and specify all available events in globalScope of Winter.
e.g. install / activate / unhandedrejection / error, etc.
In general, I think it's better (standards wise for new platforms) to use onerror/onunhandledrejection
and not Node's uncaughtException/unhandledRejection/rejectionHandled
hooks (and not ship EventEmitter) but mostly: I don't think it makes a ton of sense to standardize given the different error handling model.
Since we're discussing error
event, I think ErrorEvent
should be added into Common Minium API.
https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
Since we're discussing error event, I think ErrorEvent should be added into Common Minium API.
I don't think Node.js is interested in this if we're not shipping globalThis.addEventListener("error"
which we are currently not and have no plans to as far as I can tell.
Also, Deno for example does something different from browsers (fires "error" for unhandled rejections).
For exceptions from
Promise
, we can simply useunhandledrejection
. But how about exceptions that not come fromPromise
? Is there any way to specify the behavior?