Don't run the moose controller test if Moose isn't available
[catagits/Catalyst-Runtime.git] / t / 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
49940140 24 my $error = $_[0];
25 $error =~ s/\n/, /g;
26
27 $c->response->headers->push_header( 'X-Catalyst-Error' => $error );
dd4e6fd2 28
29 $c->NEXT::error(@_);
30}
31
321;