[Catalyst-dev] Patch to add a backtrace on error.

Dan Sully daniel at electricrain.com
Fri Apr 22 03:38:39 CEST 2005


Against svn trunk.

-Numa
-- 
"It has become appallingly obvious that our technology has exceeded our humanity." - Albert Einstein
-------------- next part --------------
Index: lib/Catalyst/Engine.pm
===================================================================
--- lib/Catalyst/Engine.pm	(revision 474)
+++ lib/Catalyst/Engine.pm	(working copy)
@@ -248,8 +248,11 @@
         my $req   = encode_entities Dumper $c->req;
         my $res   = encode_entities Dumper $c->res;
         my $stash = encode_entities Dumper $c->stash;
+        my $bt    = Catalyst::Utils::bt();
         $infos = <<"";
 <br/>
+<b><u>Backtrace</u></b><br/>
+<pre>$bt</pre>
 <b><u>Request</u></b><br/>
 <pre>$req</pre>
 <b><u>Response</u></b><br/>
Index: lib/Catalyst/Utils.pm
===================================================================
--- lib/Catalyst/Utils.pm	(revision 474)
+++ lib/Catalyst/Utils.pm	(working copy)
@@ -97,6 +97,25 @@
     return $prefix;
 }
 
+=item bt();
+
+Returns a backtrace from the current point in code.
+
+=cut
+
+sub bt {
+	my $frame = 1;
+
+	my $msg = "Backtrace:\n\n";
+
+	while (my ($filename, $line, $subroutine) = (caller($frame++))[1,2,3]) {
+
+		$msg .= sprintf("   frame %d: $subroutine ($filename line $line)\n", $frame - 2);
+	}
+
+	return $msg;
+}
+
 =back
 
 =head1 AUTHOR


More information about the Catalyst-dev mailing list