[Bps-public-commit] Path-Dispatcher branch, master, updated. f5544e06e652d47ff640e6c1d3d55afd8b2c1366
Shawn Moore
sartak at bestpractical.com
Sun Oct 17 04:59:01 EDT 2010
The branch, master has been updated
via f5544e06e652d47ff640e6c1d3d55afd8b2c1366 (commit)
via 82056990a4d39847d344db14a0e8b3abe2d6e293 (commit)
via 64f38c3b34f9e08d4e637a4c3f59fc6efe85b2ec (commit)
via 8670721c60b14af3b7e55787f6f9eaedc7bd96bc (commit)
from 418e7e91ebb4e86bbdcfd3b9ef93b06669aa2f09 (commit)
Summary of changes:
Makefile.PL | 1 +
lib/Path/Dispatcher/Dispatch.pm | 16 ++++++++++------
t/030-exceptions.t | 26 ++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 6 deletions(-)
create mode 100644 t/030-exceptions.t
- Log -----------------------------------------------------------------
commit 8670721c60b14af3b7e55787f6f9eaedc7bd96bc
Author: Florian Ragwitz <rafl at debian.org>
Date: Fri Oct 15 14:20:52 2010 +0200
Failing test for swallowing exceptions
diff --git a/t/030-exceptions.t b/t/030-exceptions.t
new file mode 100644
index 0000000..d87fb22
--- /dev/null
+++ b/t/030-exceptions.t
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Test::Exception;
+use Path::Dispatcher;
+
+{
+ package Moo;
+ use overload 'bool' => sub { 0 };
+}
+
+my $not_true = bless {}, 'Moo';
+
+my $dispatcher = Path::Dispatcher->new(
+ rules => [
+ Path::Dispatcher::Rule::CodeRef->new(
+ matcher => sub { 1 },
+ block => sub { die $not_true; "foobar matched" },
+ ),
+ ],
+);
+
+throws_ok(sub {
+ $dispatcher->run("foobar");
+}, $not_true);
commit 64f38c3b34f9e08d4e637a4c3f59fc6efe85b2ec
Author: Florian Ragwitz <rafl at debian.org>
Date: Fri Oct 15 14:21:07 2010 +0200
Stop swallowing exceptions
diff --git a/Makefile.PL b/Makefile.PL
index 0d07d17..09787c5 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,6 +5,7 @@ all_from 'lib/Path/Dispatcher.pm';
repository 'http://github.com/bestpractical/path-dispatcher';
requires 'Any::Moose';
+requires 'Try::Tiny';
build_requires 'Test::Exception';
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 62fa29b..117d906 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -1,5 +1,6 @@
package Path::Dispatcher::Dispatch;
use Any::Moose;
+use Try::Tiny;
use Path::Dispatcher::Match;
@@ -34,7 +35,9 @@ sub run {
my @results;
while (my $match = shift @matches) {
- eval {
+ my $xcpt;
+
+ try {
local $SIG{__DIE__} = 'DEFAULT';
$match->rule->trace(running => 1, match => $match)
@@ -43,14 +46,15 @@ sub run {
push @results, scalar $match->run(@args);
die "Path::Dispatcher abort\n";
+ }
+ catch {
+ $xcpt = $_;
};
- if ($@) {
- last if $@ =~ /^Path::Dispatcher abort\n/;
- next if $@ =~ /^Path::Dispatcher next rule\n/;
+ last if $xcpt =~ /^Path::Dispatcher abort\n/;
+ next if $xcpt =~ /^Path::Dispatcher next rule\n/;
- die $@;
- }
+ die $xcpt;
}
return @results if wantarray;
commit 82056990a4d39847d344db14a0e8b3abe2d6e293
Merge: 418e7e9 64f38c3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Sun Oct 17 17:58:15 2010 +0900
Merge branch 'master' of http://github.com/rafl/path-dispatcher
diff --cc lib/Path/Dispatcher/Dispatch.pm
index 276fbec,117d906..981acc8
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@@ -34,20 -35,26 +35,23 @@@ sub run
my @results;
while (my $match = shift @matches) {
- eval {
+ my $xcpt;
+
+ try {
local $SIG{__DIE__} = 'DEFAULT';
- $match->rule->trace(running => 1, match => $match)
- if $ENV{PATH_DISPATCHER_TRACE};
-
- push @results, scalar $match->run(@args);
+ push @results, $match->run(@args);
die "Path::Dispatcher abort\n";
+ }
+ catch {
+ $xcpt = $_;
};
- if ($@) {
- last if $@ =~ /^Path::Dispatcher abort\n/;
- next if $@ =~ /^Path::Dispatcher next rule\n/;
+ last if $xcpt =~ /^Path::Dispatcher abort\n/;
+ next if $xcpt =~ /^Path::Dispatcher next rule\n/;
- die $@;
- }
+ die $xcpt;
}
return @results if wantarray;
commit f5544e06e652d47ff640e6c1d3d55afd8b2c1366
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Sun Oct 17 17:58:50 2010 +0900
$exception not $xcpt
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 981acc8..bae4b69 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -35,7 +35,7 @@ sub run {
my @results;
while (my $match = shift @matches) {
- my $xcpt;
+ my $exception;
try {
local $SIG{__DIE__} = 'DEFAULT';
@@ -45,13 +45,13 @@ sub run {
die "Path::Dispatcher abort\n";
}
catch {
- $xcpt = $_;
+ $exception = $_;
};
- last if $xcpt =~ /^Path::Dispatcher abort\n/;
- next if $xcpt =~ /^Path::Dispatcher next rule\n/;
+ last if $exception =~ /^Path::Dispatcher abort\n/;
+ next if $exception =~ /^Path::Dispatcher next rule\n/;
- die $xcpt;
+ die $exception;
}
return @results if wantarray;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list