Re: Should Exceptions be Errors in the ECMAScript bindings?

On Apr 18, 2012, at 12:09 PM, Travis Leithead wrote:

>> -----Original Message-----
>> From: arv@google.com [mailto:arv@google.com] On Behalf Of Erik Arvidsson
>> 
>> I assume this has been covered before but I could not find any
>> previous discussion.
>> 
>> Would it make sense to make DOM exceptions be Error objects in the
>> ECMAScript bindings? The reason this came up (again) is that some
>> engines provide stack traces on Error objects and developers also want
>> this on DOMExceptions. If DOMExceptions where real Errors engines
>> would get that feature for "free".
> 
> I believe that WebIDL currently requires that DOM exceptions inherit from the ES "Error" prototype. This effectively makes them Errors for most purposes.
> 

In ECMAScript, prototype chain inheritance does not establish a deep semantic "is-a" relationship. In particular,
     var foo=Object.create(Error.prototype)
does not give foo any special Error object internal semantic state or behavior (eg, implementation specific stack trace semantics).

Allen

Received on Wednesday, 18 April 2012 19:34:14 UTC