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

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

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