[DGD] Fw: Re: callout cantrip

bart at wotf.org bart at wotf.org
Wed Mar 18 09:12:52 CET 2009


On Tue, 17 Mar 2009 17:53:11 -0700 (PDT), Noah Gibbs wrote
> That's a really good idea!  Definitely cleaner than the Phantasmal 
> method of re-throwing.
> 
>   I don't know the scope of TLS vars relative to atomic functions --

They are rolled back like anything else on error

> can this be used to get a function trace out of an atomic error? 
>  Phantasmal encodes it in the error string itself, but that can run 
> afoul of string length issues.

You need a similar trick. What this tls 'trick' provides is an easy way to
access the info.

What wasn't entirely clear maybe from what I posted is that the trace that was
printed is that of the error that was caught, not of any attempt to rethrow it.

For rethrowing it you'd need this information, and then pass it on to error()
in a way that your runtime_error implementation understands, so a way to
encode and pass this info in the error string is desirable anyway.

Bart.

> 
> --- On Tue, 3/17/09, bart at wotf.org <bart at wotf.org> wrote:
> 
> > From: bart at wotf.org <bart at wotf.org>
> > Subject: Re: [DGD] Fw: Re: callout cantrip
> > To: "All about Dworkin's Game Driver" <dgd at dworkin.nl>
> > Date: Tuesday, March 17, 2009, 5:24 PM
> > Well, that idea seems to work quite well..
> > 
> > a=2; 
> > b=0; 
> > catch { 
> >   return a/b; 
> > } : { 
> >   write(caught_error(1)); 
> > }
> > 
> > 
> > when called causes:
> > 
> > [CAUGHT] Division by zero
> > Object: /std/user#62, program: /std/user, line 187
> >  187 receive_message   /std/user (#62)
> >  182 _receive_message  /std/user (#62)
> >  675 receive_message   /std/player (#79)
> >   23 main              /cmds/wiz/eval
> >   10 exec              /tmp/aidil
> > 
> > Code is in the latest gurbalib distribution and in
> > subversion of course.
> > 
> > On Sat, 14 Mar 2009 16:02:48 +0100, bart wrote
> > > Talking about such 'tricks', I've been
> > pondering saving a copy of the
> > > call_stack or an 'interpreted version' of it
> > in a tls var when 
> > > encountering a caught runtime error so one can rethrow
> > it and 
> > > provide a proper trace of the caught error.
> > > 
> > > Bart.
> > 
> > --
> > Created with Open WebMail at http://www.bartsplace.net/
> > Read my weblog at http://soapbox.bartsplace.net/
> > 
> > ___________________________________________
> > https://mail.dworkin.nl/mailman/listinfo/dgd
> 
> ___________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd

--
Created with Open WebMail at http://www.bartsplace.net/
Read my weblog at http://soapbox.bartsplace.net/



More information about the DGD mailing list