mgibian has asked for the wisdom of the Perl Monks concerning the following question:
I am writting a comprehensive set of scripts for building some software. Two features are that it must log comprehensively to a file anything of use in addition to providing some informative and progress messages to stdout; and, it must be very comprehensive in its error handling.
What has me puzzled is how one captures error information for many of the basic functions within Perl, and more specifically file related functions such as open, close, copy, unlink as a few examples. The common practice for these is to code up:
My script needs to be more sophisticated in what it does in the error case than doing a simple die. I am guessing that I can put any code I need in the or case, but I have not seen any examples. Also, is the $! just a textual error message? I am thinking something like:open(...) or die ".... $!"
or something similar would do the trick?open (...) or { $errormsg = $!; $status = -1 }
Anyone out there have any experience in doing more complete and rigorous error handling in Perl?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comprehensive error handling
by dragonchild (Archbishop) on Jul 16, 2003 at 18:59 UTC | |
|
Re: comprehensive error handling
by blue_cowdawg (Monsignor) on Jul 16, 2003 at 18:44 UTC | |
|
Re: comprehensive error handling (if)
by tye (Sage) on Jul 16, 2003 at 19:07 UTC | |
|
Re: comprehensive error handling
by Aristotle (Chancellor) on Jul 16, 2003 at 18:30 UTC | |
|
Re: comprehensive error handling
by adrianh (Chancellor) on Jul 16, 2003 at 19:38 UTC | |
|
Re: comprehensive error handling
by mgibian (Acolyte) on Jul 16, 2003 at 21:55 UTC | |
by adrianh (Chancellor) on Jul 18, 2003 at 10:36 UTC |