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