Creating your own errors

Anne van Kesteren annevk at
Wed Aug 21 09:09:33 PDT 2013

On Tue, Aug 6, 2013 at 10:03 PM, Brendan Eich <brendan at> wrote:
> That's not the issue. If you don't care about which (whatever the set of
> standard error types), you might as well toss a coin. But clearly we have
> some implicit rule or rules informing when to use RangeError vs. TypeError.
> Or are the rules explicit?
> Saying the Java-esque "Error class hierarchy" is not useful for dispatching
> also ignores matching in catch clauses, on the Harmony agenda.
> But even if we think everything here is a mistake, it is at least an
> attractive nuisance that trips up developers and other standards'
> caretakers. We need some ground rules and FAQ entries for when to use Type
> vs. Range, and why-no-Value/Domain.

And having this sooner rather than later would be welcome. There's new
APIs coming up that want to mint new types of errors and it seems we
might be stuck with the situation that returns a
specific name rather than "DOMException". We can probably still kill
DOMError, but the alternative should be clear.

If in the end people are expected to check I don't think it
matters much DOM has a catchall DOMException object that represents a
bunch of distinct names.

And FWIW, the distinct names are occasionally useful for certain APIs,
e.g. when you want to react differently between a network error and an
end-user terminating the operation.

More FWIW, describes the situation
we have today. Timely advice much appreciated.


More information about the es-discuss mailing list