From: Yuval Kogman Date: Tue, 1 Nov 2005 22:47:37 +0000 (+0000) Subject: Add dump_these method to Catalyst, which returns the structures dumped on error X-Git-Tag: 5.7099_04~1061 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7f92deef6d24d2a7618ba679892189838fcb4dfd Add dump_these method to Catalyst, which returns the structures dumped on error --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index b2a966e..49d8fc3 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -749,6 +749,19 @@ Dispatch request to actions. sub dispatch { my $c = shift; $c->dispatcher->dispatch( $c, @_ ) } + +=item dump_these + +Returns a list of 2-element array references (name, structure) pairs that will +be dumped on the error page in debug mode. + +=cut + +sub dump_these { + my $c = shift; + [ Request => $c->req ], [ Response => $c->res ], [ Stash => $c->stash ],; +} + =item $c->execute($class, $coderef) Execute a coderef in given class and catch exceptions. diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 095c4ff..2c39782 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -117,15 +117,14 @@ sub finalize_error { my $req = encode_entities Dumper $c->req; my $res = encode_entities Dumper $c->res; my $stash = encode_entities Dumper $c->stash; - $infos = <<""; -
-Request
-
$req
-Response
-
$res
-Stash
-
$stash
+ $infos = join( + "\n", "
", + map { + sprintf "%s
\n
%s
", $_->[0], + encode_entities( Dumper $_->[1] ) + } $c->dump_these + ); } else { $title = $name;