Skip to content
Browse files

added 500 test

  • Loading branch information...
1 parent 815ba73 commit a52802bd9df4f3795a05a303c83951886d07a6ca @typester committed Aug 11, 2009
Showing with 32 additions and 0 deletions.
  1. +6 −0 lib/Ark/Core.pm
  2. +26 −0 t/error.t
View
6 lib/Ark/Core.pm
@@ -605,6 +605,12 @@ sub handle_request {
if ( my $error = $context->error->[-1] ) {
chomp $error;
$self->log( error => 'Caught exception in engine "%s"', $error );
+
+ unless ($self->debug) {
+ my $res = $context->response;
+ $res->status(500);
+ $res->body('Internal Server Error');
+ }
}
return $context->response;
View
26 t/error.t
@@ -0,0 +1,26 @@
+use Test::Base;
+
+plan 'no_plan';
+
+{
+ package T;
+ use Ark;
+
+ package T::Controller::Root;
+ use Ark 'Controller';
+
+ has '+namespace' => default => '';
+
+ sub index :Path {
+ my ($self, $c) = @_;
+ die;
+ }
+}
+
+use Ark::Test 'T', components => [qw/Controller::Root/];
+
+my ($res, $c) = ctx_request(GET => '/');
+is($res->code, 500, '500 ok');
+is($res->content, 'Internal Server Error', 'error content ok');
+like($c->error->[-1], qr/^Died at/, 'error msg ok');
+

0 comments on commit a52802b

Please sign in to comment.
Something went wrong with that request. Please try again.