[libcatmandu-perl] 51/85: Wrote the Reject die into a reject goto at request of Nicolas Steenlant
Jonas Smedegaard
dr at jones.dk
Tue May 20 09:56:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.91
in repository libcatmandu-perl.
commit 88973c2bc911860d781f48956088db19c7e408c6
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Thu May 15 16:58:47 2014 +0200
Wrote the Reject die into a reject goto at request of Nicolas Steenlant
---
lib/Catmandu/Fix.pm | 8 +++++---
lib/Catmandu/Fix/Bind/maybe.pm | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/Catmandu/Fix.pm b/lib/Catmandu/Fix.pm
index 45447c4..de5277d 100644
--- a/lib/Catmandu/Fix.pm
+++ b/lib/Catmandu/Fix.pm
@@ -123,14 +123,16 @@ sub emit {
# Loop over all the fixes and emit their code, binded to Binds if required
$perl .= $self->emit_fixes($self->fixes);
- $perl .= "${var};";
+ $perl .= "return ${var};";
+ $perl .= "__REJECT__: return ${reject_var};";
$perl .= "} or do {";
$perl .= $self->emit_declare_vars($err, '$@');
# TODO throw Catmandu::Error
- $perl .= qq|if (ref(${err}) eq 'Catmandu::Fix::Reject') { ${err} } else { die ${err}.Data::Dumper->Dump([${var}], [qw(data)]); }|;
+ $perl .= qq|die ${err}.Data::Dumper->Dump([${var}], [qw(data)]);|;
$perl .= "};";
$perl .= "};";
+
if (%$captures) {
my @captured_vars = map {
$self->emit_declare_vars($_, '$_[1]->{'.$self->emit_string($_).'}');
@@ -179,7 +181,7 @@ sub emit_fixes {
sub emit_reject {
my ($self) = @_;
my $reject_var = $self->_reject_var;
- "die $reject_var;";
+ "goto __REJECT__;";
}
sub emit_fix {
diff --git a/lib/Catmandu/Fix/Bind/maybe.pm b/lib/Catmandu/Fix/Bind/maybe.pm
index 1f5e983..7e3c3a2 100644
--- a/lib/Catmandu/Fix/Bind/maybe.pm
+++ b/lib/Catmandu/Fix/Bind/maybe.pm
@@ -51,7 +51,7 @@ sub bind {
$res = $func->($self->value($mvar));
};
- if ($@ && ref $@ eq 'Catmandu::Fix::Reject') {
+ if ($@) {
die $@;
}
elsif ($@) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git
More information about the Pkg-perl-cvs-commits
mailing list