Can you refer me to the list of built-in exception I can throw/catch and how can I define a new exception (if possible) and throw/catch it.An exception is just anything that calls die with an object, since that is the native perl equivalent of other languages' throw. As for defining new exceptions, it's really just a matter of defining catch and throw methods and calling die with an object in throw. Although even this isn't necessary, but it will keep it in line with current syntax and behaviour of exceptions in the Error module. It would also be a good idea to inherit from either Error or Error::Simple to make your life much simpler.
Here's an example of a new exception
{ package KaPow; @ISA = 'Error::Simple'; sub throw { warn "Holy thrown exceptions Batman!\n"; ## must die with object die KaPow->new($_[1]); } } use Error ':try'; try { throw KaPow("The Riddler strikes again!"); } catch KaPow with { warn "this just in - $_[0]"; }; __output__ Holy thrown exceptions batman! this just in - The Riddler strikes again! at pmsopw_284549.pl line 9.
_________
broquaint
In reply to Re: Re: Re: Error module
by broquaint
in thread Error module
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |