Subject: | Debug error page causes exception |
Caught exception in engine "Can't call method "finalize_headers" on an
undefined value at /home/autarch/projects/Catalyst-
Runtime/lib//Catalyst/Response.pm line 60, <DATA> line 998."
On IRC, hobbs found the issue, which is the call to "$c->res-
Show quoted text
>_clear_context" in the Catalyst::Engine code.
He also proposed a simple fix:
diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm
index 77bd1c5..df8e247 100644
--- a/lib/Catalyst.pm
+++ b/lib/Catalyst.pm
@@ -1626,8 +1626,12 @@ that will be dumped on the error page in debug
mode.
sub dump_these {
my $c = shift;
+ my $res = { %{ $c->res } }; # Shallow copy
+ # Don't show response context in the dump
+ $res->_clear_context;
+
[ Request => $c->req ],
- [ Response => $c->res ],
+ [ Response => $res ],
[ Stash => $c->stash ],
[ Config => $c->config ];
}
diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm
index 4781e45..daf53d1 100644
--- a/lib/Catalyst/Engine.pm
+++ b/lib/Catalyst/Engine.pm
@@ -180,9 +180,6 @@ sub finalize_error {
$title = $name = "$name on Catalyst $Catalyst::VERSION";
$name = "<h1>$name</h1>";
- # Don't show context in the dump
- $c->res->_clear_context;
-
# Don't show body parser in the dump
$c->req->_clear_body;
-------------------------
Longer term, I'd really like to see Catalyst switch to
Data::Dump::Streamer, which would give us control over how things are
serialized. This has the big benefit of letting app developers define a
DDS_freeze method for their classes to control app object display.