From: Martin K. <mar...@fe...> - 2010-06-22 18:17:39
|
Hi Thorsten, it looks like the DESTROY method clobbers $@ - so there are two possible solutions: Either the one you described (which is fixing symptoms), or localizing $@ like in sub DESTROY { local $@; eval { } } This restores $@ after the enclosing block. And I heard yesterday in my local perl mongers group that perl 5.13 automatically localizes $@ in DESTROY, but I fear upgrading is not an option ;-) What I don't read from your mails is whether your problem is already fixed by re-throwing a SOAP::Fault - so please send again if not. Regards, Martin Am Dienstag, den 22.06.2010, 14:15 +0200 schrieb Thorsten Schöning: > Guten Tag Thorsten Schöning, > am Dienstag, 22. Juni 2010 um 12:18 schrieben Sie: > > > Now I have the problem again and hunted it down to an eval{} in the > > Package DBIx::Log4perl::db. > > I've tested my code again and it seems I have this problem: > > http://search.cpan.org/~elliotjs/Perl-Critic-1.106/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm > > I do have DESTROY which is always called and calls > DBIx::Log4perl::db::disconnect indirectly while disocnnecting from the > database. In this function eval is used successfully, which resets $@ > and SOAP-Lite can't detect the former die anymore, which let the code > stop because of an error. > > What I don't understand is, if I do a eval{} myself to catch the > exception and save $@ in a variable, $@ doesn't seem to be reset. If I > die directly in that eval again, no matter if I die with $@ or > something else, SOAP-Lite sends an empty response again. > > Won't work: > eval > { > someClass->new()->someMethod(); > } or die 'test'; > [download] > > Does work: > my $retVal = undef; > eval > { > someClass->new()->someMethod(); > } or $retVal = SOAP::Fault->new(faultstring => $@); > die $retVal; > [download] > > $retVal will have the proper message from $@ from the die in > someMethod. I would have expected that $@ is always cleared because of > DESTROY is always called in the eval above. > > Mit freundlichen Grüßen, > > Thorsten Schöning > |