Changeset 29323
- Timestamp:
- 01/31/09 01:45:11 (4 years ago)
- Location:
- lang/perl/HTTP-Engine-Middleware/trunk
- Files:
-
- 3 modified
-
lib/HTTP/Engine/Middleware.pm (modified) (2 diffs)
-
lib/HTTP/Engine/Middleware/DebugScreen.pm (modified) (1 diff)
-
t/200_middlewares/debugscreen.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-Engine-Middleware/trunk/lib/HTTP/Engine/Middleware.pm
r29322 r29323 20 20 is => 'ro', 21 21 isa => 'Str', 22 ); 23 24 has 'diecatch' => ( 25 is => 'rw', 26 isa => 'Bool', 22 27 ); 23 28 … … 177 182 } 178 183 } 179 my $res = eval { $handle->($req) }; 184 my $res; 185 my $msg; 186 { 187 local $@; 188 $self->diecatch(0); 189 eval { $res = $handle->($req) }; 190 $msg = $@ if !$self->diecatch && $@; 191 } 192 die $msg if $msg; 180 193 for my $middleware (reverse @{ $self->middlewares }) { 181 194 my $instance = $self->_instance_of->{$middleware}; -
lang/perl/HTTP-Engine-Middleware/trunk/lib/HTTP/Engine/Middleware/DebugScreen.pm
r29321 r29323 36 36 $self->stacktrace_required(0); 37 37 38 localize_elem '%SIG', '__DIE__' => sub { died($self, @_) } => SUB UP;38 localize_elem '%SIG', '__DIE__' => sub { $c->diecatch(1); died($self, @_) } => SUB UP; 39 39 40 40 $req; -
lang/perl/HTTP-Engine-Middleware/trunk/t/200_middlewares/debugscreen.t
r29321 r29323 8 8 plan skip_all => "Scope::Upper is not installed: $@" if $@; 9 9 10 plan tests => 4;10 plan tests => 6; 11 11 12 12 use HTTP::Engine; … … 16 16 use HTTP::Engine::Middleware; 17 17 18 my $mw = HTTP::Engine::Middleware->new; 19 $mw->install( 'HTTP::Engine::Middleware::DebugScreen', { powerd_by => 'HE::Middleware test' } ); 18 { 19 my $mw = HTTP::Engine::Middleware->new; 20 $mw->install( 'HTTP::Engine::Middleware::DebugScreen', { powerd_by => 'HE::Middleware test' } ); 21 my $res = HTTP::Engine->new( 22 interface => { 23 module => 'Test', 24 request_handler => $mw->handler( 25 sub { die 'ERROR TEST HE' } 26 ), 27 }, 28 )->run( HTTP::Request->new( GET => 'http://localhost/') ); 29 my $out = $res->content; 20 30 21 my $res = HTTP::Engine->new( 22 interface => { 23 module => 'Test', 24 request_handler => $mw->handler( 25 sub { die 'ERROR TEST HE' } 26 ), 27 }, 28 )->run( HTTP::Request->new( GET => 'http://localhost/') ); 29 my $out = $res->content; 31 is $res->code, '500'; 32 like $out, qr/ERROR TEST HE/; 33 like $out, qr/Powered by HE::Middleware test/; 34 like $out, qr/request_handler => \$mw->handler\(/; 35 } 30 36 31 is $res->code, '500'; 32 like $out, qr/ERROR TEST HE/; 33 like $out, qr/Powered by HE::Middleware test/; 34 like $out, qr/request_handler => \$mw->handler\(/; 37 { 38 my $mw = HTTP::Engine::Middleware->new; 39 $mw->install(); 40 my $res = HTTP::Engine->new( 41 interface => { 42 module => 'Test', 43 request_handler => $mw->handler( 44 sub { die 'ERROR TEST HE' } 45 ), 46 }, 47 )->run( HTTP::Request->new( GET => 'http://localhost/') ); 48 my $out = $res->content; 49 50 is $res->code, '500'; 51 is $out, 'internal server errror'; 52 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)