4dc0d5716087c933b6bb53819811c78e89878185
[catagits/Catalyst-Runtime.git] / t / live / lib / Catalyst / Plugin / Test / Errors.pm
1 package Catalyst::Plugin::Test::Errors;
2
3 use strict;
4
5 sub error {
6     my $c = shift;
7
8     unless ( $_[0] ) {
9         return $c->NEXT::error(@_);
10     }
11
12     if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) {
13         $c->response->status(404);
14     }
15     
16     if ( $_[0] =~ /^Couldn\'t forward/ ) {
17         $c->response->status(404);
18     }    
19
20     if ( $_[0] =~ /^Caught exception/ ) {
21         $c->response->status(500);
22     }
23
24     $c->response->headers->push_header( 'X-Catalyst-Error' => $_[0] );
25
26     $c->NEXT::error(@_);
27 }
28
29 1;