W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: WebIDL generated TypeErrors and promises

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 28 Jun 2013 10:55:58 -0400
Message-ID: <51CDA3FE.1090500@mit.edu>
To: public-script-coord@w3.org
On 6/28/13 10:44 AM, Marcos Caceres wrote:
> When using a method that vends a promise, it's not clear to me what should happen when WebIDL says to throw a TypeError.
>
> Like, given:
>
> interface Foo{
> Promise bar(object obj);
> };
>
> //Does this throw a TypeError
> //or is boo called with the TypeError?
> fooInstance.bar(123).then(yay,boo);

Per current spec it throws a TypeError.

Just like it throws if called on the wrong this object, say.

And just like it would throw if you had:

   interface Foo {
     Promise bar(DOMString str);
   };

   fooInstance.bar(
     { toString: function() { throw "xyz"; } }
   ).then(whatever);

I think this behavior is perfectly reasonable, for what it's worth...

-Boris
Received on Friday, 28 June 2013 14:56:28 UTC

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