Here's a patch to Plack::Middleware::StackTrace that seems to work, but not 
nearly as elegant as Aristotle's solution.

--- StackTrace.pm.orig 2016-09-09 00:25:40.552397674 -0700
+++ StackTrace.pm 2016-09-09 23:21:17.084080486 -0700
@@ -20,7 +20,9 @@
 
     my ($trace, %string_traces, %ref_traces);
     local $SIG{__DIE__} = sub {
-        $trace = $StackTraceClass->new(
+        undef $trace unless $env->{'plack.stacktrace.rethrow'};
+
+        $trace ||= $StackTraceClass->new(
             indent => 1, message => munge_error($_[0], [ caller ]),
             ignore_package => __PACKAGE__, no_refs => 1,
         );

So with that, if you set $env->{'plack.stacktrace.rethrow'} to true, it 
reuses the previously built trace.
I'm not sure how safe that is for the general case, but it seems to work 
for me. It's obviously intended
more for use by a framework than an end-user.

So the idiom would be something like:

eval { dispatch() };
if ($@) {
  $env->{'plack.stacktrace.rethrow'} = 1;
  die "now with more suds! $@";
}

Thoughts?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"psgi-plack" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to psgi-plack+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to