Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / t / live / lib / Catalyst / Plugin / Test / Errors.pm
CommitLineData
dd4e6fd2 1package Catalyst::Plugin::Test::Errors;
2
3use strict;
4
5sub 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
291;