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

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

From: <bugzilla@jessica.w3.org>
Date: Fri, 15 Aug 2014 03:56:08 +0000
To: public-script-coord@w3.org
Message-ID: <bug-26517-3890-RHI2VpBPR0@http.www.w3.org/Bugs/Public/>

Yutaka Hirano <yhirano@google.com> changed:

           What    |Removed                     |Added
                 CC|                            |yhirano@google.com

--- Comment #17 from Yutaka Hirano <yhirano@google.com> ---
> 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"
Is the rule applied recursively?
For example, imagine we provide a Promise-returning function foo and it uses
another function bar.

function foo(x, y) {
  if (typeof x !== 'number) { throw TypeError('x must be a number'); }
  bar(-x, y);
  return new Promise(...);

Should we enclose bar with try-catch?

You are receiving this mail because:
You are on the CC list for the bug.
Received on Friday, 15 August 2014 03:56:11 UTC

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