Dru has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
Can someone point me in the right direction on error handling with packages? I have some die statements in a custom package, in case certain files don't exist, but it's preventing the rest of my script from executing when the die is encountered. Ideally, I would like to build in an error checking mechanism that if the package dies, I can catch this within the script and perform some action based on it. I thought something like this would work:
My error handling skills are limited to "die" and "warn". I would appreciate if someone could point me in the right direction on how to handle this.
Thanks,
Dru
Can someone point me in the right direction on error handling with packages? I have some die statements in a custom package, in case certain files don't exist, but it's preventing the rest of my script from executing when the die is encountered. Ideally, I would like to build in an error checking mechanism that if the package dies, I can catch this within the script and perform some action based on it. I thought something like this would work:
but $status never prints anything if the package dies. I have "return 1" at the end of the package, so maybe that's my problem?use strict; user warnings; use VPNUser qw(get_vpn_user $user $fullname $location); my $ip = shift; my $time = shift; my $status = get_vpn_user($ip, $time); print "$status\n";
My error handling skills are limited to "die" and "warn". I would appreciate if someone could point me in the right direction on how to handle this.
Thanks,
Dru
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Error Handling with Packages
by holli (Abbot) on May 23, 2005 at 16:04 UTC | |
Re: Error Handling with Packages
by ghenry (Vicar) on May 23, 2005 at 16:05 UTC | |
Re: Error Handling with Packages
by Forsaken (Friar) on May 23, 2005 at 16:06 UTC | |
by ghenry (Vicar) on May 23, 2005 at 16:12 UTC | |
by salva (Canon) on May 23, 2005 at 19:15 UTC | |
by Forsaken (Friar) on May 23, 2005 at 20:17 UTC | |
by salva (Canon) on May 23, 2005 at 20:44 UTC | |
Re: Error Handling with Packages
by sasikumar (Monk) on May 23, 2005 at 16:11 UTC | |
by salva (Canon) on May 23, 2005 at 19:00 UTC | |
by anjoschu (Sexton) on May 24, 2005 at 08:55 UTC | |
Re: Error Handling with Packages
by Dru (Hermit) on May 23, 2005 at 19:38 UTC |
Back to
Seekers of Perl Wisdom