[Wellington-pm] Rethrowing exceptions

Ewen McNeill ewen at naos.co.nz
Sun Nov 5 20:04:52 PST 2006


Hi,

In perl you can (sort of) do exception handling by doing:

eval { 
   # some stuff
   die "It broke";
};

if ($@) {
  print "Oh dear, it didn't work, because: $@\n";
}

However I can't find any obvious way of rethrowing an exception (as
opposed to generating a new exception), so that it's possible to catch 
the exception, do some cleanup, and then propogate the exception to 
let something else do the cleanup.

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.

Is this possible?

Ewen


More information about the Wellington-pm mailing list