Browse files

local $@ and then die $@ is not cool. See Try::Tiny :)

  • Loading branch information...
1 parent bcaf68a commit 2028f4b7fa7a56f45613a177e2a0ecd54ba1710c @miyagawa miyagawa committed Sep 15, 2009
Showing with 16 additions and 12 deletions.
  1. +16 −12 lib/Plack/Impl/Standalone.pm
View
28 lib/Plack/Impl/Standalone.pm
@@ -138,23 +138,27 @@ sub handle_connection {
}) {
Sys::Sendfile::sendfile($conn, $res->[2]);
} else {
- local $@;
+ my $err;
my $done;
- eval {
- Plack::Util::foreach(
- $res->[2],
- sub {
- $self->write_all($conn, $_[0], $self->{timeout})
- or die "failed to send all data\n";
- },
- );
- $done = 1;
+ {
+ local $@;
+ eval {
+ Plack::Util::foreach(
+ $res->[2],
+ sub {
+ $self->write_all($conn, $_[0], $self->{timeout})
+ or die "failed to send all data\n";
+ },
+ );
+ $done = 1;
+ };
+ $err = $@;
};
unless ($done) {
- if ($@ =~ /^failed to send all data\n/) {
+ if ($err =~ /^failed to send all data\n/) {
return;
} else {
- die $@;
+ die $err;
}
}
}

0 comments on commit 2028f4b

Please sign in to comment.