CC: | 305045 [...] rt.noris.net |
Subject: | die() inside on_error handler doesn't work |
If I use a die() inside an on_error handler to parse(), virtually
nothing happens, i. e.
perl -MNet::DNS::ZoneFile::Fast -e 'Net::DNS::ZoneFile::Fast::parse(
text => "broken", on_error => sub { die "@_" } )'
won't give any output at all or stop program execution.
The reason for this is that the error() sub-routine gets called inside
the eval block originating from parse(), and since on_error turns the
soft_error option on, parse() will only return undef.
Attached is a (IMHO somewhat ugly but working) patch.
If you do not plan to apply it or change this behaviour by other means,
it should IMHO at least be documented.
Regards,
fany
PS: The Changes file of Net::DNS::ZoneFile::Fast 1.0 only contains
revisions up to 0.6.1.
Subject: | die.patch |
--- /usr/local/lib/perl5/site_perl/5.10.0/Net/DNS/ZoneFile/Fast.pm 2008-05-26 19:14:06.000000000 +0200
+++ Net/DNS/ZoneFile/Fast.pm 2008-09-17 17:55:57.275241405 +0200
@@ -145,6 +145,7 @@
}
};
if ($@) {
+ if ( $@ =~ /^USER ERROR: (.*)/s ) { die $1 }
return undef if $param{soft_errors};
die;
}
@@ -205,6 +206,7 @@
sub error
{
if ($on_error) {
+ local $SIG{__DIE__} = sub { die "USER ERROR: @_" };
$on_error->($ln, @_);
} else {
warn "@_, line $ln\n" if $soft_errors && !$quiet;