It definitely is a very decent package.
However, it doesn't seem to handle plain die()
correctly (or at least the way I expect it to)
try {
die "foobar";
}
catch {
print "failed\n";
exit;
}
print "ok";
After running this code (having included Error.pm etc.), I do see the "failed" string, however, I can't seem to be able to see the die string ("foobar"). Here's what the package dump (via perldb "V Error" command) looks inside catch {} clause:
$("" = 'stringify'
$(0+ = 'value'
$Debug = 1
$VERSION = 0.15
$Depth = 0
$() = 1
%OVERLOAD = (
'dummy' => 1
)
Clearly, the Error package doesn't seem to have a record of the original die string. For my intents and purposes I need just that since I have to wrap my exception handling code around older code that relies on eval/die as it's exception handling mechanism.
Despite of this, there does seem to be a (lengthy) workaround this problem:
try {
eval {
die "foobar";
};
if ($@) {
throw Error::Bad($@);
}
}
catch Error::Bad with {
my $err = shift;
print "Failed: $err\n";
exit;
}
print "ok";
However, even this code doesn't work for some reason =/. Here's what I get:
okCan't use string ("1") as a HASH ref while "strict refs" in use at E
+rror.pm line 183.
I would be greatful if someone could explain me how this should be made to work ;-).
Thank you for pointing to Error.pm, however. Looking at it as is, I think I could simply modify it a bit here and there to fit my needs (and hopefully make it useful to others who are in a like position).
|
"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
|
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.