Skip to content

Commit

Permalink
allow HTTPExceptions to optionally rethrow the exception
Browse files Browse the repository at this point in the history
  • Loading branch information
doy committed Jun 15, 2011
1 parent 0cf44ef commit 990fa45
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Plack/Middleware/HTTPExceptions.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Plack::Middleware::HTTPExceptions;
use strict;
use parent qw(Plack::Middleware);
use Plack::Util::Accessor qw(rethrow);

use Carp ();
use Try::Tiny;
Expand Down Expand Up @@ -46,8 +47,13 @@ sub transform_error {
$e->can('as_string') ? $e->as_string :
overload::Method($e, '""') ? "$e" : undef;
} else {
$code = 500;
$env->{'psgi.errors'}->print($e);
if ($self->rethrow) {
die $e;
}
else {
$code = 500;
$env->{'psgi.errors'}->print($e);
}
}

if ($code !~ /^[3-5]\d\d$/) {
Expand Down

0 comments on commit 990fa45

Please sign in to comment.