local $SIG{__DIE__} = sub {
my $err = shift;
if(UNIVERSAL::isa($err, 'Exception::Class')) {
die $err; # re-throw
}
else {
# Otherwise construct a MyException with $err as a string
die MyException::Default->throw(message => "$err");
}
};