Thread

Posted on Mon Nov 27 19:53:26 2006 by hpham
Cannot trap Object-Insideout error in mod_perl
Hi guys, I got this weird problem when invoking an undefined method of an Insideout class. The error I got outside the mod_perl environment is something like this: template error: undef error - OIO::Method error: Can't locate object method "fix ed_rate" via package "Emerge::VO::Contract" Package: Template::Document File: edit_recycling_contract.htm Line: 115 ... The code uses the eval { ... }; if ( $@ ) {...} construct. Now, the same piece of code running in mod_perl env. generates a segfault, forcing Apache to restart. I tried to localize $SIG{__DIE__}, but still got the same problem. Does anyone have any idea why the error couldn't be trapped? Thanks.
Direct Responses: 3630 | Write a response
Posted on Mon Nov 27 20:16:41 2006 by jdhedden in response to 3629
Re: Cannot trap Object-Insideout error in mod_perl
With the segfault, I'd say it may be a bug in the version of Perl/mod_perl you're using. Trying to set $SIG{__DIE__} will not have any affect.

You may be able to work around the problem by testing for the method using 'can' before trying to use it inside the 'eval':
if (! $class_name->can($method_name)) { # Throw an 'undefined method' error } # or if (! $obj->can($method_name)) { # Throw an 'undefined method' error }
Write a response