[Bug 26517] Methods that return promises are unable to throw exceptions

https://www.w3.org/Bugs/Public/show_bug.cgi?id=26517

Dimitri Glazkov <dglazkov@chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dglazkov@chromium.org

--- Comment #14 from Dimitri Glazkov <dglazkov@chromium.org> ---
(In reply to Ian 'Hixie' Hickson from comment #13)
> > If we get some in-between option, like "[throwOnInvalidInput]" or whatever,
> > then some APIs might use this and others might not... then, as an author, you
> > always need to check the API contract (so to wrap in try/catch)
> 
> No, you don't. Nobody puts every method call in a try-catch today, just like
> nobody is going to be checking for a rejection on a promise for this kind of
> bug.
> 
> As a developer you never need to look at what the API will do when you use
> it incorrectly. You only need to use it correctly.
> 
> When you use it incorrectly, you should get an exception, the same way as
> when you call the wrong API.

FWIW, based on personal experience with Promises, I think that the current
design leads to sadness very quickly. No sooner than I wrote 30 lines of code
using Promises, I was already stumped by an accidental typo (like this, for
instance http://jsbin.com/cosic/1/edit?js,console). FWIW :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Thursday, 14 August 2014 21:01:29 UTC