Hi Abelard,

* Abelard <abelardhoff...@gmail.com> [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 system state";
> >         ref $old_die_handler ? goto &$old_die_handler : die @_;
> >     };
> >     dispatch();  # no eval{}
>
> Yes! Exactly like that. Except for this:
>
>   Modification of a read-only value attempted at ./try line 13.
>
> Is there a way around that?

Err, of course? Presumably something like this:

    {
        my $old_die_handler = $SIG{__DIE__};
        local $SIG{__DIE__} = sub {
            my $msg = shift;
            unshift @_, $msg . " lots of details about system state";
            ref $old_die_handler ? goto &$old_die_handler : die @_;
        };
        dispatch();
    }

(Just as untested as my previous scribble.) (E.g. this time I remembered
to add a block to limit the scope of the `local`.)


* Abelard <abelardhoff...@gmail.com> [2016-09-10 08:36]:
> Here's a patch to Plack::Middleware::StackTrace that seems to work,

You don’t want that.

The __DIE__ handler gets called for any and all exceptions. During
unwind there can be other caught-and-handled exceptions after the
__DIE__ handler is called but before the eval{} returns, and the __DIE__
handler will be called for all of those too. If you only keep the stack
trace for the last thrown exception, that won’t necessarily match the
exception caught by the eval{} block.

That’s why the %string_traces/%ref_traces stuff was added in the first
place:

https://github.com/plack/Plack/issues/475
https://github.com/plack/Plack/pull/476

Yes, it keeps you from rethrowing your exception easily. It has to, in
order to allow other code to do its own exception handling in peace,
without getting mixed up with yours. A mechanism to disable that is not
“supporting rethrowing” as the option name in your patch suggests, it’s
“reintroducing an old bug”.

The only way you can avoid mismatches is to modify the exception you
care about before it gets into P:M::StackTrace’s hands.

That’s why I proposed what I proposed.


Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

-- 

--- 
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