Create branch register_actions.
[catagits/Catalyst-Runtime.git] / t / lib / Catalyst / Plugin / Test / Errors.pm
CommitLineData
dd4e6fd2 1package Catalyst::Plugin::Test::Errors;
2
3use strict;
ae29b412 4use MRO::Compat;
dd4e6fd2 5
6sub error {
7 my $c = shift;
8
9 unless ( $_[0] ) {
ae29b412 10 return $c->next::method(@_);
dd4e6fd2 11 }
12
13 if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) {
14 $c->response->status(404);
15 }
16
17 if ( $_[0] =~ /^Couldn\'t forward/ ) {
18 $c->response->status(404);
19 }
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
ae29b412 30 $c->next::method(@_);
dd4e6fd2 31}
32
331;