Why not do:
my $base_class = '...'; # base class for exceptions my $error_class = '...'; # my error class sub fixerror(;$) { my $e = @_ ? $_[0] : $@; return $e if blessed( $e ) && $e->isa( $base_class ); return $error_class->new( $e ); } sub try(&) { my $code = $_[0]; eval { &$code() }; $@ ? fixerror($@) : undef; }
That way you don't have a callback that has the potential of getting called multiple times.
In reply to Re: How to prevent exception stringification after error in require/use?
by thenaz
in thread How to prevent exception stringification after error in require/use?
by vokbuz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |