[Wellington-pm] Rethrowing exceptions
michael at diaspora.gen.nz
michael at diaspora.gen.nz
Sun Nov 5 20:18:59 PST 2006
>What I'm looking for is something equivilent to rethrowing the same
>exception object in Java, or an empty throw in C++. I'm particularly
>interested in being able to, eg, get the code reference/stack trace at
>the point something actually went wrong, rather than at the point that
>the exception is rethrown.
I can't speak to fancy stack traces, and things, but this works for me:
eval {
eval { die "It broke"; };
if ($@) { print $@; die $@; }
};
if ($@) { print $@; }
Prints:
It broke at t.pl line 2.
It broke at t.pl line 2.
So re-throwing is easy; the original exception was "re-thrown".
Check out Grant's presentation from last month, specifically
http://wellington.pm.org/archive/200610/exceptions/slide18.html and ff.
-- michael.
More information about the Wellington-pm
mailing list