Skip Menu |

This queue is for tickets about the Syntax-Feature-Try CPAN distribution.

Report information
The Basics
Id: 104404
Status: resolved
Priority: 0/
Queue: Syntax-Feature-Try

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

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



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.
P.S. the noTimestamp option can be removed in the example program.
Because this module (Syntax::Feature::Try) locally overrides $SIG{__DIE__}. so try {} catch {} syntax may lead to problem/conflict with any code that overrides $SIG{__DIE__}.
Hmm, I have come across this problem before. In https://rt.perl.org/Public/Bug/Display.html?id=24806 Rafael Garcia-Suarez suggests a way to add a new __WARN__ or __DIE__ handler stacked on top of what was set before. Could this module use the same trick?
Can you try simple test? override "Syntax::Feature::Try::_rethrow" and remove "local $SIG{__DIE__}". *Syntax::Feature::Try::_rethrow = sub { die @_ }; In your script a check if it is working with CGI::Carp? And also test if it report correct line-number of error? Thank you.
Can you try simple test? override "Syntax::Feature::Try::_rethrow" and remove "local $SIG{__DIE__}". *Syntax::Feature::Try::_rethrow = sub { die @_ }; In your script a check if it is working with CGI::Carp? And also test if it report correct line-number of error? Thank you.
Yes, this script reports the error correctly: use warnings; use strict; use 5.018; use syntax 'try'; use CGI::Carp qw(fatalsToBrowser noTimestamp); *Syntax::Feature::Try::_rethrow = sub { die @_ }; try { die 'fa' } catch ($err) { die $err }
I removed "local $SIG{__DIE__} = undef;" from Syntax::Feature::Try::_rethrow. I hope everything will be working without this line ;-) Dne Pá 04.pro.2015 09:12:33, EDAVIS napsal(a): Show quoted text
> Yes, this script reports the error correctly: > > use warnings; > use strict; > use 5.018; > use syntax 'try'; > use CGI::Carp qw(fatalsToBrowser noTimestamp); > *Syntax::Feature::Try::_rethrow = sub { die @_ }; > try { die 'fa' } catch ($err) { die $err }
Fixed in 1.003
Dne Po 07.pro.2015 03:05:12, tnt napsal(a): Show quoted text
> Fixed in 1.003