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

Perl v5.6.1 built for i686-linux
kernel 2.4.27
Red Hat Linux release 7.3 (Valhalla)

Hi, can anyone offer any advice?
I am using Class::DBI in a DB wrapper object
... use strict; use warnings; use base 'Class::DBI'; ...
I am using the object, and getting dies - the die message I am getting is
Can't locate Class/DBI/__/Base.pm in ...


Strangely, this doesn't cause what I would normally expect from a die, which when hit from the browser is a 500 error. It returns a page as normal...
I am catching the die sig like this:
... $SIG{__DIE__} = \&prepareToDie; ... sub prepareToDie{ my $message=shift; # report and log the error etc ... die($message); }
and this has and is working on our systems for years.

The script using this wrapper does what it should insofar as it reads the database and returns the expected values etc I cannot find any calls to Class::DBI::__::Base; anywhere on the box, or any directory __ etc. I have looked at Class::DBI and ...nothing.
I have run the identical code on a different box:

v5.8.0 built for i386-linux-thread-multi
Linux 2.4.21-15.EL
Red Hat Enterprise Linux ES release 3 (Taroon Update 2)

and I dont get the error at all.


Now, clearly I am missing something here, can you tell me what it is?
any help much appreciated.

Replies are listed 'Best First'.
Re: Help! cannot solve a "die" ing problem with Class::DBI
by perrin (Chancellor) on Sep 15, 2004 at 12:43 UTC
    Make sure you have the same version of Class::DBI and Ima::DBI installed on both machines. Also, your DIE handler may be messing up exception handling in Class::DBI (or anything else). A universal DIE handler is not safe to use with code that throws and catches exceptions.
      Thanks for your response perrin. I will check our Ima, although I know that the Class::DBI versions are the same. Can you expand on why a universal Die handler is not neccessarily a safe idea please?
        The problem with a DIE handler is that it catches other people's exceptions when they were trying to use eval{} blocks. See this for more.
Re: Help! cannot solve a "die" ing problem with Class::DBI
by dondelelcaro (Monk) on Sep 16, 2004 at 00:01 UTC
    Strangely, this doesn't cause what I would normally expect from a die, which when hit from the browser is a 500 error. It returns a page as normal...
    Not knowing exactly where you're ending up getting the error, it's hard to say, but if you've already started sending output to the client, they will never see the error. In cases where it's important that they see the error, you probably want to hold off on sending any output until the very end of the script. [If this is what is happening, when you view source, you might actually end up seeing the error somewhere hidden at the bottom.]