At 07:40 PM 8/15/00 -0600, Tony Olekshy wrote:
> > > catch { ... }
> > >
> > > Invoked if unwinding. This is a post-finally catch,
> >
> > What's this for? If the finally block throws?
>
>Actually it's invoked if we're unwinding at that point, according to
>the definition of unwinding contained in v0.1. RFC 88 gives this
>example (but it uses "unwind" instead of the final "catch"):
>
> try { TryToFoo; }
> catch { TryToHandleFailure; }
> finally { TryToCleanUp; }
> catch { throw "Can't cleanly Foo."; };
>
>In our production code we often add such blocks to major API entry
>points; that is how we get unwind stack tracebacks like the one
>shown in RFC 88:
Um, I still don't geddit. Why don't you put that last throw in the finally
block? That's where I would have expected to find it.
> > You want: while handling an exception, throwing another exception
> > pushes the first one onto a stack which could be reported en masse
> > when the coup de gras arrives. Like VMS error cascading. You do
> > this with a _link attribute of exceptions. Cool, I can dig that.
>
>Yup, as per the traceback shown above. This is going to become more
>important when Perl starts using exceptions for error handling, for
>example, if an open throws and a calling DB module throws, and then
>your UI catches it, you are (in many cases) going to want to know
>why the open threw.
>
> > I want: exceptions to contain 'file' and 'line' attributes which
> > are arrays that get a location pushed on every time an exception
> > bubbles up through a scoping level.
>[snip]And the following output was generated:
>
> Exception
>
> $ = Try::throw('Exception') called from scott2.pm[8].
> $ = main::pling('Test') called from scott2.pm[4].
> $ = main::bar('Test') called from scott1.pl[1].
> $ = main::foo('Test') called from scott1.pl[8].
> $ = Try::try(CODE(0xca8830)) called from scott1.pl[9].
> $ = Try::try(CODE(0xca2418), 'catch', CODE(0x10b18ac))
> called from scott1.pl[8].
>
>If I'm not mistaken, exceptions must bubble up through the call
>stack as at the point the exception is thrown, so if we capture
>that stack traceback then, we have all the info. Do you still
>want the file/line array?
Yes, I want to be able to get at it C<caller>-like. You're just dumping it.
--
Peter Scott
Pacific Systems Design Technologies