W3C home > Mailing lists > Public > public-media-capture@w3.org > October 2016

[mediacapture-image] Rejecting promises vs throwing

From: Dan Dascalescu via GitHub <sysbot+gh@w3.org>
Date: Tue, 11 Oct 2016 22:49:00 +0000
To: public-media-capture@w3.org
Message-ID: <issues.opened-182394057-1476226137-sysbot+gh@w3.org>
dandv has just created a new issue for 
https://github.com/w3c/mediacapture-image:

== Rejecting promises vs throwing ==
After [the change from ImageCaptureError to 
DOMException](https://github.com/w3c/mediacapture-image/pull/93) 
(which has "also rewritten the 4 method's descriptions to be more 
Promise-based and homogeneous"), I'd have to update [the 
polyfill](https://github.com/dandv/imagecapture) to throw a new 
`DOMException` if the stream is not `live`, but reject in case of 
other operational errors.

Any reason for this inconsistency which goes again [common 
recommendations](http://exploringjs.com/es6/ch_promises.html#_tips-for-error-handling)?

> For operational errors, each function should support exactly one way
 of signaling errors. For Promise-based functions that means not 
mixing rejections and exceptions, which is the same as saying that 
they shouldn’t throw exceptions.

Please view or discuss this issue at 
https://github.com/w3c/mediacapture-image/issues/94 using your GitHub 
account
Received on Tuesday, 11 October 2016 22:49:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:26:37 UTC