W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

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

From: <bugzilla@jessica.w3.org>
Date: Mon, 04 Aug 2014 18:32:04 +0000
To: public-script-coord@w3.org
Message-ID: <bug-26517-3890@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=26517

            Bug ID: 26517
           Summary: Methods that return promises are unable to throw
                    exceptions
           Product: WebAppsWG
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: WebIDL
          Assignee: cam@mcc.id.au
          Reporter: ian@hixie.ch
        QA Contact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-script-coord@w3.org
            Blocks: 25662

http://heycam.github.io/webidl/#es-operations

The spec for operations says:

# If O has a return type that is a promise type, then:
#  1. Let reject be the initial value of %Promise%.reject.
#  2. Return the result of calling reject with %Promise% as the this
#     object and the exception as the single argument value.

This is bad practice, IMHO, as discussed in detail here:
   https://github.com/domenic/promises-unwrapping/issues/24

If I want my API to reject the promise, then I'll reject the promise. If I want
it to throw an exception, then I should be able to throw an exception.

In particular, if an API is called with bad arguments, then the exception
should throw immediately, just like if it's name was typoed. The behaviour of:

   foo.bar(-1); // only accepts positive numbers

...should be the same as the behaviour of:

   foo.baz(1); // there's no "baz" method, it's called "bar"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Received on Monday, 4 August 2014 18:32:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC