On Wed, Aug 21, 2013 at 5:21 PM, Domenic Denicola
<[email protected]> wrote:
> FWIW for non-DOM code I see people using `instanceof` much more often than 
> checking `name`.

In public-script-coord and elsewhere people have argued that
instanceof is an indication of badness:
http://lists.w3.org/Archives/Public/public-script-coord/2013JulSep/0225.html


> 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`.

That seems like a lot of unnecessary bloat for something that's rather trivial.


> 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. But since we're not, creating a large 
> hierarchy seems best, since it allows you to preserve all the usual 
> properties of JS errors. The only downside of it is that it creates a large 
> hierarchy, which seems like less of a downside than e.g. having an error 
> whose `.name` is not equal to its `.constructor.name`.

Allen suggested having .subname. But I'm not sure we can still do that
and it also seems silly to make these exceptions second-class
citizens.


-- 
http://annevankesteren.nl/
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to