A way of explicitly reporting exceptions
C. Scott Ananian
ecmascript at cscott.net
Tue Jun 24 06:38:54 PDT 2014
I am ambivalent about where it goes; it depends to some degree with
how the feature is implemented.
`setTimeout(function() { throw e; }, 0);` is ugly, but it seems to
have most of the behavior you want. There are similar mechanisms with
promises and jobs that could be used. I believe Allan said that the
"use the standard uncaught exception handler" behavior is already in
the standard. If we're talking about tweaks to make this approach
more palatable (`Promise.throw(e)` ?) then the ES6 spec is
appropriate.
Alternatively, one could view this as part of the `console`
functionality, since what seems to be wanted is simply easier access
to the debugging capabilities of modern web consoles, like the
already-existing `console.trace(message)` which prints `message` along
with a stack trace. (And some people want to be able to pass
additional flags to have certain special behaviors in a debugger.)
That would belong on the DOM side (or wherever the cross-platform
`console` spec is kept).
Finally, it hasn't been discussed much, but some platforms provide
explicit access to the 'uncaughtException' handler. In python this is
[`sys.excepthook`](https://docs.python.org/3/library/sys.html#sys.excepthook)
and in node this is [an `uncaughtException` event on the process
object](http://nodejs.org/api/process.html#process_event_uncaughtexception).
If we wanted to standardize something like that I'm not sure which
spec that would belong in.
--scott
More information about the es-discuss
mailing list