Subject: | Misleading error messages due to MRMA object destruction |
Hi Jerry,
As promised (some time ago) here is a report about MRMA producing
potentially misleading error messages. It's more of an enhancement
request than a bug.
A script is attached to reproduce what happens.
In essence, if a non-blessed exception is thrown in code that contains a
MRMA object then the error handling in the object destruction modifies
the error, labelling it as an OIO error and starting a stack trace from
within the object destruction code. The rest of the details still point
to the original source of the error, so it is just the embellishments
that MRMA (or OIO) is adding that are the issue here.
If the exception is blessed then it passes straight through.
One possible solution/workaround is to check the stack and see if the
source is in an OIO or MRMA module and only then add the embellishments.
I'm not sure how simple (or brittle) that is, as other classes might be
extending OIO or MRMA.
Alternately the error message could be edited to say something along the
lines of "possible OIO error", unless it definitely comes from OIO or
MRMA code.
Regards,
Shawn.
Subject: | misleading_exception.pl |
use strict;
use warnings;
use Carp;
use Math::Random::MT::Auto;
use Exception::Class ('MyException');
my %die_types = (
'Blessed exception' => sub {MyException->throw ('Blessed exception thrown')},
'croak' => sub {croak 'Croaking'},
'die' => sub {die 'Dying'},
);
while (my ($type, $sub) = each %die_types) {
print "---- $type:\n\n";
eval {
runner ($sub);
};
print $@ if $@;
print "\n\n\n";
}
sub runner {
my $sub = shift;
my $prng = Math::Random::MT::Auto->new;
&$sub();
}