Proxy questions

David Bruant bruant.d at
Sun Jan 20 09:03:44 PST 2013

Le 20/01/2013 16:49, Kevin Smith a écrit :
> Got it.  And one more (thanks for bearing with me)
I forked the thread. Go crazy if you have other questions :-)

> what affect does throwing an error have within a trap?
You can think of it as an internal error, very much like 
Object.defineProperty throws a TypeError when the first argument isn't 
an object.

>     var target = {
>       foo: function() {; console.log("after bar"); },
>       bar: 0
>     };
>     var proxy = new Proxy(target, {
>       get: function(obj, name) {
>         if (name === "bar") throw new Error("boom");
>         return obj[name];
>       }
>     });
> Does the stack unwind as with normal error handling?  Does "after bar" 
> get logged?  (FF18 answers yes to the first and no to the second 
> question.)
I agree with FF18 here.
This case is relatively easy and the get trap is supported by Firefox 
implementation, but always aware that for now, some traps aren't 
implemented, some invariant-related checks aren't performed, other are 
overly performed. You can see the known issues in the dependency tree of 
the direct proxy bug:


More information about the es-discuss mailing list