Say I have a module pane, which is a subclass wrapper for a Foo module. I want calls to Bar methods to accurately mimic Foo - right down to fatal errors. Still easy enough; I just call the SUPER method.
sub stuff {
SUPER::stuff(@_);
}
But let's say that I want to catch, register and reconstruct any fatal errors SUPER::stuff(). The first two steps are simple:
sub stuff {
eval {
SUPER::stuff(@_);
};
$@ and log("Naughty, naughty: $@");
}
... but I don’t know how to do the last part. How to throw an error so that the caller cannot distinguish between the call Foo->stuff()and the call Bar->stuff()? Can I just paste die $@after the log statement and expect it to do what I want, or are there any nuances here that are likely to put me in trouble?
source
share