sub rethrow_exception { my $exception = shift; # debug that the exception is being rethrow, so we can trace it in debugs debug( 'Exception ' . ( ref($exception) || 'GENERIC Perl Died: ' . $exception ) . ' being rethrown', 'true' ); my @trace = caller_string(); # Check if its a string... if ( !ref $exception ) { Zymonic::Exception::from_die->throw( error => 'GENERIC Perl Died: ' . $exception, email => 'sysadmin', zymocallers => \@trace ); } elsif ( ref($exception) !~ /Zymonic::Exception/ ) { Zymonic::Exception::from_die->throw( error => Dumper($exception), email => 'sysadmin', zymocallers => \@trace ); } else { # We have an exception - just rethrow it, adding additional trace to it $exception->{zymocallers} = [ ( ref( $exception->{zymocallers} ) ? @{ $exception->{zymocallers} } : () ), @trace ]; $exception->rethrow(); } }