Re: Plack::Middleware::StackTrace and eval

2016-09-12 Thread Aristotle Pagaltzis
* Abelard [2016-09-12 21:12]: > What's the issue if $old_die_handler uses goto instead of die? This is > a worry about the inifinite loop again, or something else? There is this bit in perlvar: When a "__DIE__" hook routine returns, the exception processing continues as it would have in

Re: Plack::Middleware::StackTrace and eval

2016-09-12 Thread Abelard
On Monday, September 12, 2016 at 5:40:35 AM UTC-7, Aristotle Pagaltzis wrote: > > * Abelard > [2016-09-12 08:36]: > > The difference being that before we call the original die handler, > > we reassign SIG{__DIE__} back to it, which I guess re-enables the > > recursive call protection. > > Ah

Re: Plack::Middleware::StackTrace and eval

2016-09-12 Thread Aristotle Pagaltzis
* Abelard [2016-09-12 08:36]: > The difference being that before we call the original die handler, > we reassign SIG{__DIE__} back to it, which I guess re-enables the > recursive call protection. Ah, makes sense. But there’s no mechanism that restores your own die handler, is there? It seems to m

Re: Plack::Middleware::StackTrace and eval

2016-09-11 Thread Abelard
This seems to work. use strict; use warnings; my $app = sub { my $old_die_handler = $SIG{__DIE__}; local $SIG{__DIE__} = sub { # warn "my die called from ", caller, "\n"; my $msg = shift; unshift @_, $msg . " lots of details about system state"; die @_ unless $old_die_hand

Re: Plack::Middleware::StackTrace and eval

2016-09-11 Thread Abelard
On Saturday, September 10, 2016 at 12:40:47 PM UTC-7, Aristotle Pagaltzis wrote: > > * Abelard > [2016-09-10 08:12]: > > On Friday, September 9, 2016 at 9:44:51 PM UTC-7, Aristotle Pagaltzis > wrote: > > > Are you looking for something like this? > > > > > > my $old_die_handler = $SIG{_

Re: Plack::Middleware::StackTrace and eval

2016-09-10 Thread Aristotle Pagaltzis
Hi Abelard, * Abelard [2016-09-10 08:12]: > On Friday, September 9, 2016 at 9:44:51 PM UTC-7, Aristotle Pagaltzis wrote: > > Are you looking for something like this? > > > > my $old_die_handler = $SIG{__DIE__}; > > local $SIG{__DIE__} = sub { > > $_[0] .= " lots of details about s

Re: Plack::Middleware::StackTrace and eval

2016-09-10 Thread Ævar Arnfjörð Bjarmason
On Sat, Sep 10, 2016 at 8:26 AM, Abelard wrote: > So the idiom would be something like: > > eval { dispatch() }; > if ($@) { > $env->{'plack.stacktrace.rethrow'} = 1; > die "now with more suds! $@"; > } > > Thoughts? Using that eval idiom is a logic error. The $@ is only significant if the e

Re: Plack::Middleware::StackTrace and eval

2016-09-09 Thread Abelard
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)

Re: Plack::Middleware::StackTrace and eval

2016-09-09 Thread Abelard
On Friday, September 9, 2016 at 9:44:51 PM UTC-7, Aristotle Pagaltzis wrote: > > * Abelard > [2016-09-09 17:48]: > > I think I need a way to modify the exception that > > Plack::Middleware::StackTrace sees in its DIE handler before it receives > > it... > > Are you looking for something like

Re: Plack::Middleware::StackTrace and eval

2016-09-09 Thread Aristotle Pagaltzis
* Abelard [2016-09-09 17:48]: > I think I need a way to modify the exception that > Plack::Middleware::StackTrace sees in its DIE handler before it receives > it... Are you looking for something like this? my $old_die_handler = $SIG{__DIE__}; local $SIG{__DIE__} = sub { $_[0] .=

Re: Plack::Middleware::StackTrace and eval

2016-09-09 Thread Abelard
On Friday, September 9, 2016 at 12:25:15 AM UTC-7, Ævar Arnfjörð Bjarmason wrote: > > This is not Plack specific, but in general in Perl: > > my $stack; > local $SIG{__DIE__} = sub { $stack = longmess() }; > eval { code(); 1 } > or do { > my $error = $@ || "Zombie Error"; > say "Yo

Re: Plack::Middleware::StackTrace and eval

2016-09-09 Thread Ævar Arnfjörð Bjarmason
On Fri, Sep 9, 2016 at 9:18 AM, Abelard wrote: > Hi. > > I have an app that catches exceptions and appends data to it. In > development, I'd like to use Plack::Middleware::StackTrace to display the > trace. However, since I'm rethrowing a modified error message, it isn't > finding the Devel::Strac