Ensure all exceptions are objects
local $SIG{__DIE__} = sub { my $error = shift; if(UNIVERSAL::isa($error, 'Exception::Class')) { die $error; # re-throw } else { die MyException::Default->throw( message => "$error" ); } };
- Otherwise don’t use $SIG{__DIE__} – it’s global
- See also: $^S or $EXCEPTIONS_BEING_CAUGHT