ES4 draft: Error classes

Lars Hansen lhansen at adobe.com
Tue Mar 18 12:05:04 PDT 2008


> -----Original Message-----
> From: Garrett Smith [mailto:dhtmlkitchen at gmail.com] 
> Sent: 18. mars 2008 11:57
> To: Lars Hansen
> Cc: es4-discuss Discuss
> Subject: Re: ES4 draft: Error classes
> 
> On Mon, Mar 17, 2008 at 12:11 PM, Lars Hansen 
> <lhansen at adobe.com> wrote:
> > (Didn't know who to follow up to so lamely following up to myself.)
> >
> >  Straw proposal for debugging information and backtraces in  error 
> > objects.
> >
> 
> 
> >  Issues to watch out for:
> >
> >  * Security / privacy problems if debugging information can
> >   leak to arbitrary code (realistic attack scenario).
> >
> >  * Code that gets to look into the caller's lexical environment
> >   is hard to control, makes possibly unwarranted assumptions
> >   about the implementation, may preclude tail calls.  So
> >   "magic" functionality comes at a cost.
> >
> >
> >  Proposal
> >
> >  * New property Error.prototype.context, value null
> >
> >  * New property Error.prototype.backTrace, value null
> >
> >  * When the run-time system throws a standard error object under
> >   well-defined circumstances (eg, when it throws a TypeError
> >   because a value of an incompatible type is stored in a
> >   type-annotated property) then it may, at its discretion,
> >   create properties "context" and "backTrace" on the new error
> >   object.  The values in these properties will reveal
> >   information about the static and dynamic location of the error.
> >
> 
> How does the stack trace get set? Given a user-defined Error 
> type - IllegalDateFormatError - what do callers of the 
> DateFormat have to do to make functions "capture" the stack trace?

Read further.

> >   The property "backTrace", if not null, must be an array of
> >   objects of the same type as stored in "context", representing
> >   a stack trace taken at the point of the creation of the error
> >   object.  The object at property 0 in "backTrace" represents
> >   the innermost stack frame and is the same object that is stored
> >   in the "context" property.
> >
> 
> Should the stack trace be - backTrace -  or  - stackTrace - ?
> 
> 
> >  * New subclass of Error called AssertionError
> >
> >  * New expression forms assert(E), assert(E1,E2)
> >
> 
> 
> What does this have to do with getting a stack trace?

See your question above.

--lars



More information about the Es4-discuss mailing list