X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Fhttp_exceptions.t;h=ad6544abc2405970040ad38df6de8c7b1b3a84ee;hp=5cb31175e0d63b69c127d2baef6007cf1612d5aa;hb=9c86666a0171945d0b543cfb81510621fc42d6af;hpb=f384c84887409fd343be4751b40a232ebf224b5c diff --git a/t/http_exceptions.t b/t/http_exceptions.t index 5cb3117..ad6544a 100644 --- a/t/http_exceptions.t +++ b/t/http_exceptions.t @@ -12,10 +12,6 @@ use Plack::Test; { package MyApp::Exception; - use overload - # Use the overloading thet HTTP::Exception uses - bool => sub { 1 }, '""' => 'as_string', fallback => 1; - sub new { my ($class, $code, $headers, $body) = @_; return bless +{res => [$code, $headers, $body]}, $class; @@ -35,8 +31,14 @@ use Plack::Test; }; } + package MyApp::AnotherException; + + sub new { bless +{}, shift } + + sub code { 400 } + sub as_string { 'bad stringy bad' } - + package MyApp::Controller::Root; use base 'Catalyst::Controller'; @@ -60,6 +62,11 @@ use Plack::Test; 403, ['content-type'=>'text/plain'], ['Forbidden']); } + sub from_code_type :Local { + my $e = MyApp::AnotherException->new; + die $e; + } + sub classic_error :Local { my ($self, $c) = @_; Catalyst::Exception->throw("Ex Parrot"); @@ -107,6 +114,14 @@ test_psgi $psgi, sub { test_psgi $psgi, sub { my $cb = shift; + my $res = $cb->(GET "/root/from_code_type"); + is $res->code, 400; + is $res->content, 'bad stringy bad', 'bad stringy bad'; + unlike $res->content, qr'HTTPExceptions', 'HTTPExceptions'; +}; + +test_psgi $psgi, sub { + my $cb = shift; my $res = $cb->(GET "/root/classic_error"); is $res->code, 500; like $res->content, qr'Ex Parrot', 'Ex Parrot'; @@ -127,5 +142,5 @@ test_psgi $psgi, sub { # in the callbacks might never get run (thus all ran tests pass but not all # required tests run). -done_testing(14); +done_testing(17);