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

eval { open($DBH, $dbh = DBI->connect('dbi:ODBC:driver=microsoft access driv +er (*.mdb);dbq=C:\main.mdb')) or die MyFileException->new("Unable to open file - $DBH"); }; if ($@) { # now $@ contains the exception object of type MyFileException # print "raman"; print $@->getErrorMessage(); # where getErrorMessage() is a method in MyFileException class }
i am getting an error when my code is fine that is my database connectivity is fine
the error
Software error:

Can't locate object method "getErrorMessage" via package "Can't locate object method "new" via package "MyFileException" (perhaps you forgot to load "MyFileException"?) at C:\Inetpub\wwwroot\amexpmo\login\amex\logprg2.cgi line 27. " (perhaps you forgot to load "Can't locate object method "new" via package "MyFileException" (perhaps you forgot to load "MyFileException"?) at C:\Inetpub\wwwroot\amexpmo\login\amex\logprg2.cgi line 27. "?) at C:\Inetpub\wwwroot\amexpmo\login\amex\logprg2.cgi line 34.

Replies are listed 'Best First'.
Re: exception handling
by xorl (Deacon) on Jun 09, 2005 at 12:57 UTC
    Where do you define MyFileException and getErrorMessage? Do you have a "use MyFileExceptionclass;" statement somewhere? Is there a "new" method in that class?

    The error message clearly indicates MyFileException and getErrorMessage are not defined.

    I think we need more code to figure out what is going on here.

Re: exception handling
by aukjan (Friar) on Jun 09, 2005 at 12:38 UTC
    What do you want??? Please type a well formulated question... Then whe can help you... Please read How (Not) To Ask A Question first and then repost the question...

    .:| If it can't be fixed .. Don't break it |:.