domenic / promises-unwrapping

The ES6 promises spec, as per September 2013 TC39 meeting
1.23k stars 95 forks source link

[guide] Rejections Should Be Errors should cater for DOMException #84

Closed marcoscaceres closed 10 years ago

marcoscaceres commented 11 years ago

The advice given in the error section is a bit problematic, as DOM recommends using DOMExceptions, which are not instances of ES Error :( I agree that we should Error instead, but there is a lot precedence for using DOMException on the platform.

marcoscaceres commented 11 years ago

updated issue title.

erights commented 11 years ago

@marcoscaceres Where is this advice?

domenic commented 11 years ago

Actually DOMException is instanceof Error; it's DOMError that's the problem. But yes, we should specifically tell people not to use DOMError, and instead to use DOMException.

marcoscaceres commented 11 years ago

@erights it's not quite explicit in the spec, but basically: http://dom.spec.whatwg.org/#errors

@domenic see: http://dom.spec.whatwg.org/#domexception ... it does not extend Error.

domenic commented 11 years ago

Oh poop. Well, in that case, neither DOMError nor DOMException is currently suitable for use with promises.

domenic commented 11 years ago

/cc @annevk @sicking

marcoscaceres commented 11 years ago

The test:

try{document.body.appendChild(document.body)}catch(e){ e instanceof Error }

Chrome: true Firefox: false Safari: true

annevk commented 10 years ago

DOMException has problems, this is not one of them. DOMError is planned for removal.

marcoscaceres commented 10 years ago

Yeah, turned out that WebIDL defines what the prototype is. It's still very messy the way it's defined and Anne filed a bug for this long ago. Sorry for the wild goose chase.