Creating your own errors

Erik Arvidsson erik.arvidsson at
Wed Aug 21 10:46:38 PDT 2013

On Wed, Aug 21, 2013 at 12:21 PM, Domenic Denicola
<domenic at> wrote:
> FWIW for non-DOM code I see people using `instanceof` much more often than checking `name`.
> Thus I personally think that creating a bunch of new `DOMException` subtypes would be the way to go, e.g. a `PermissionDeniedError` whose `.name` is `PermissionDeniedError` and whose `.__proto__` is `DOMException`.
> If we were starting from scratch we'd probably just have a single `DOMException` (probably named `DOMError` actually) with a `.code` property that can vary between types of errors.

`.code` implies numeric error codes which has gone out of fashion.


More information about the es-discuss mailing list