Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a CGI that uses:

use CGI::Carp (fatalsToBrowser);

If I make a mistake, or if there's a runtime error, it tells me.

But, if an error occurs within a class method, like:

$obj->method();

The app silently dies. Processing just stops at that point, no error on the page.

This seems to be true whenever I make a mistake in a class method, regardless of the mistake. My question is, is this normal for perl oo? I haven't done much oo stuff in perl. Silent pavlovian errors are just too impractical.

Replies are listed 'Best First'.
Re: Class methods die silently?
by perrin (Chancellor) on Sep 22, 2003 at 22:23 UTC
    First, if $obj is an object, then $obj->method() is an object method, not a class method.

    The whole "fatalsToBrowser" thing is kind of a hack and people frequently have problems with it. In this case, I'm guessing that your object method is doing something with eval{} blocks to catch exceptions and this CGI::Carp is ignoring it, but it could be other things as well. You are much better off getting rid of fatalsToBrowser and just using the error_log instead.

      There's nothing in the error log about it. (I'm on pair.com, btw)
        Try it without fatalsToBrowser. If you still have nothing in the error log it means something in your code is supressing the error message. That's about as much help as we can give you unless you post some sample code that shows the problem.
Re: Class methods die silently?
by Cody Pendant (Prior) on Sep 23, 2003 at 02:33 UTC
    What happens if you do
    $obj->method() || die "$!";
    ?

    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print