[Catalyst-commits] r11876 - in
Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib:
Catalyst/TraitFor/Context TestApp
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Tue Nov 17 22:09:52 GMT 2009
Author: zby
Date: 2009-11-17 22:09:51 +0000 (Tue, 17 Nov 2009)
New Revision: 11876
Added:
Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/Catalyst/TraitFor/Context/TestErrors.pm
Modified:
Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestApp/Context.pm
Log:
error is now in Context (t/aggregate/live_recursion.t and others)
Added: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/Catalyst/TraitFor/Context/TestErrors.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/Catalyst/TraitFor/Context/TestErrors.pm (rev 0)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/Catalyst/TraitFor/Context/TestErrors.pm 2009-11-17 22:09:51 UTC (rev 11876)
@@ -0,0 +1,28 @@
+package Catalyst::TraitFor::Context::TestErrors;
+
+use Moose::Role;
+
+before error => sub {
+ my $c = shift;
+ unless ( $_[0] ) {
+ return;
+ }
+
+ if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) {
+ $c->response->status(404);
+ }
+
+ if ( $_[0] =~ /^Couldn\'t forward/ ) {
+ $c->response->status(404);
+ }
+
+ if ( $_[0] =~ /^Caught exception/ ) {
+ $c->response->status(500);
+ }
+
+ my $error = $_[0];
+ $error =~ s/\n/, /g;
+ $c->response->headers->push_header( 'X-Catalyst-Error' => $error );
+};
+
+1;
Modified: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestApp/Context.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestApp/Context.pm 2009-11-17 21:45:11 UTC (rev 11875)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestApp/Context.pm 2009-11-17 22:09:51 UTC (rev 11876)
@@ -2,6 +2,7 @@
use Moose;
extends 'Catalyst::Context';
with 'Catalyst::TraitFor::Context::TestHeaders';
+with 'Catalyst::TraitFor::Context::TestErrors';
if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
with 'CatalystX::LeakChecker';
More information about the Catalyst-commits
mailing list