Skip Menu |

This queue is for tickets about the MojoX-Renderer-Xslate CPAN distribution.

Report information
The Basics
Id: 131291
Status: open
Priority: 0/
Queue: MojoX-Renderer-Xslate

People
Owner: Nobody in particular
Requestors: tbusch [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.14
Fixed in: (no value)



Subject: __DIE__ signal handler captures error wrapped by eval
I noticed that the __DIE__ signal handler captures any error even if it is wrapped by an eval statement. That means exceptions cannot be handled properly. I found a way out which is to replace the __DIE__ signal handler by the following: local $SIG{__DIE__} = sub { my ($package, $filename, $line, $subroutine) = caller(1); if (!$subroutine || $subroutine ne '(eval)') { $xslate_err = shift; } };
On 2019-12-29 10:34:45, TBUSCH wrote: Show quoted text
> I noticed that the __DIE__ signal handler captures any error even if > it is wrapped by an eval statement. That means exceptions cannot be > handled properly. > > I found a way out which is to replace the __DIE__ signal handler by > the following: > > local $SIG{__DIE__} = sub { > my ($package, $filename, $line, $subroutine) = caller(1); > if (!$subroutine || $subroutine ne '(eval)') { > $xslate_err = shift; > } > };
Better is to check the value of $^S, which all __DIE__ handlers ought to do.
Show quoted text
> Better is to check the value of $^S, which all __DIE__ handlers ought to do.
Nice!! Thanks for your help. So the __DIE__ signal handler should be: local $SIG{__DIE__} = sub { if (!$^S) { $xslate_err = shift; } };
Sorry for being dull-witted, but I'm having trouble to understand what you're trying to achieve. Given that the handler is currently created directly inside an "eval" (https://github.com/gray/mojox-renderer-xslate/blob/master/lib/MojoX/Renderer/Xslate.pm#L64), I wonder if $^S wouldn't *always* be true, anyway? I certainly would've liked to test this if only I understood just what your code would look like: could you post some code fragment to illustrate?