Commit | Line | Data |
dd4e6fd2 |
1 | package Catalyst::Plugin::Test::Errors; |
2 | |
3 | use strict; |
4 | |
5 | sub error { |
6 | my $c = shift; |
7 | |
8 | unless ( $_[0] ) { |
c462faf0 |
9 | return $c->NEXT::error(@_); |
dd4e6fd2 |
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; |