Skip Menu |

This queue is for tickets about the WWW-Scripter-Plugin-JavaScript CPAN distribution.

Report information
The Basics
Id: 108646
Status: resolved
Priority: 0/
Queue: WWW-Scripter-Plugin-JavaScript

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

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



Subject: WWW::Scripter::Plugin::JavaScript::Guard makes $@ not usable
I though this is a bug of WWW::Scripter, so first created it there: https://rt.cpan.org/Ticket/Display.html?id=108645 Copy of this ticket below. After eval() method $@ becomes always empty. Even after explicit die(). This makes exceptions handling not usable. Try test below. Expected output: "Error - Fatality!". Actual output: "No errors". use strict; use WWW::Scripter; eval { my $scripter = WWW::Scripter->new; $scripter->use_plugin('JavaScript'); $scripter->eval("var t = false;"); die "Fatality!"; }; if (my $err = $@) { die "Error - $err"; } warn "No errors"; Solution I found is simple: --- lib/WWW/Scripter/Plugin/JavaScript.pm.orig 2015-11-10 15:04:57.442103176 +0600 +++ lib/WWW/Scripter/Plugin/JavaScript.pm 2015-11-10 15:05:11.673215672 +0600 @@ -192,7 +192,7 @@ package WWW::Scripter::Plugin::JavaScript::Guard; sub new { bless \(my $object = pop) } -DESTROY { eval { ${$_[0]}->destroy } } +DESTROY { local $@; eval { ${$_[0]}->destroy } } # ------------------ DOCS --------------------# Can you apply this patch and make new release? Thanks.
On Tue Nov 10 04:07:51 2015, OLEG wrote: Show quoted text
> I though this is a bug of WWW::Scripter, so first created it there: > https://rt.cpan.org/Ticket/Display.html?id=108645 > Copy of this ticket below. > > After eval() method $@ becomes always empty. Even after explicit > die(). This makes exceptions handling not usable. > Try test below. Expected output: "Error - Fatality!". Actual output: > "No errors". > > use strict; > use WWW::Scripter; > > eval { > my $scripter = WWW::Scripter->new; > $scripter->use_plugin('JavaScript'); > $scripter->eval("var t = false;"); > die "Fatality!"; > }; > if (my $err = $@) { > die "Error - $err"; > } > > warn "No errors"; > > Solution I found is simple: > > --- lib/WWW/Scripter/Plugin/JavaScript.pm.orig 2015-11-10 > 15:04:57.442103176 +0600 > +++ lib/WWW/Scripter/Plugin/JavaScript.pm 2015-11-10 > 15:05:11.673215672 +0600 > @@ -192,7 +192,7 @@ > package WWW::Scripter::Plugin::JavaScript::Guard; > > sub new { bless \(my $object = pop) } > -DESTROY { eval { ${$_[0]}->destroy } } > +DESTROY { local $@; eval { ${$_[0]}->destroy } } > > > # ------------------ DOCS --------------------# > > Can you apply this patch and make new release? > Thanks.
Sorry for the delay. I have just uploaded version 0.009 with your fix.