I am trying to do the exception handling in perl using the try/catch method, but i encountered error of "Can't locate object method "catch" via package "HException" (perhaps you forgot to load "HException"?) at error.pl line 27."
I try to add the use HException but I received another error like:
Can't locate HException.pm in @INC (@INC contains: /nfs/site/2.0
Here is my code, I mask the use HException out because i dont think i need to add that in after all since it should be in the library /nfs/site/2.0. Any idea will be good!
Code:use lib '/nfs/site/2.0/'; use strict; use warnings; use HSDApi; #use HException; use Error qw(:try); my $dbname = "debug_tools"; # See 2nd section for how to get your project's name. my $dsn="${dbname}_pre"; # If connecting to the staging db, set this to ${dbname}_pre my $reader = new HDataReader($dsn); # Creates a reader and connects to the db. # Put the API calls in a try-catch block try { print "Let's see if it fails...\n"; $reader->execQuery("SELECT * FROM processing") # This should throw an HException if it fails } #catch Error with { catch HException with { my $ex = shift; # Get hold of the exception object # handle the exception print $ex->getErr(); };



Bookmarks