error is now in Context (t/aggregate/live_recursion.t and others)
[catagits/Catalyst-Runtime.git] / t / lib / Catalyst / TraitFor / Context / TestErrors.pm
CommitLineData
0e74c6cd 1package Catalyst::TraitFor::Context::TestErrors;
2
3use Moose::Role;
4
5before error => sub {
6 my $c = shift;
7 unless ( $_[0] ) {
8 return;
9 }
10
11 if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) {
12 $c->response->status(404);
13 }
14
15 if ( $_[0] =~ /^Couldn\'t forward/ ) {
16 $c->response->status(404);
17 }
18
19 if ( $_[0] =~ /^Caught exception/ ) {
20 $c->response->status(500);
21 }
22
23 my $error = $_[0];
24 $error =~ s/\n/, /g;
25 $c->response->headers->push_header( 'X-Catalyst-Error' => $error );
26};
27
281;