Subject: | Interaction with CGI::Carp |
Hi, I have noticed some interaction between Syntax::Feature::Try and CGI::Carp. This latter module provides a die() handler which you can use to spew error messages to the user's browser - handy for quick CGI scripts or for debugging. CGI::Carp was until recently a core module but for perl 5.22 it is being pushed out to CPAN.
I don't yet know what exactly tickles the bug but I hope you will allow me to report it here to see if anyone has an idea. If an exception is rethrown from inside a catch{} block then CGI::Carp's error handler is not called somehow. For example
use warnings;
use strict;
use 5.018;
use syntax 'try';
use CGI::Carp qw(fatalsToBrowser noTimestamp);
$SIG{__DIE__} = \&CGI::Carp::die;
#### die 'ga';
try { die 'fa' }
catch ($err) { die $err }
If you uncomment the marked line then you will see CGI::Carp::die is getting called as expected. But if an exception is called from inside the catch block then somehow that error handler is not called and the message is thrown to the top level.
The odd thing is that an ordinary subroutine set as $SIG{__DIE__} does work, so I don't yet know what kind of weirdness is breaking it in this case.