|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Re: Error handling - how much/where/how?by ruoso (Curate) |
| on Jun 13, 2005 at 10:10 UTC ( #466090=note: print w/ replies, xml ) | Need Help?? |
|
It's an option to use a common use error handling library. As sometimes giving the error on the return of the sub is not a good option (for example a sub that can return any value). I use the Error library. It implements the try/catch syntax, enables printing the stack trace (as someone suggested on this thread) and doesn't require other things from people who use your module, since the exception is a regular die (with some info saved inside Error). I like this approuch because it's easier to handle errors from methods that can throw many types of exceptions, you can programatically do something when *this* error and otherthing when *that* error very easy.
daniel
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||