in reply to What Are The Rules For Subs And Modules When Fed Wrong Input
When writing objects I usually set an global variable $ERROR upon failure and return undef. $ERROR is then made available via an a method. This way I can have the script decide if it can live with that. An example code in the script could be the following, which is what I normally do.
my $mod = Module->new () or die Module->error (); my $foo = $mod->method () or warn $mod->error ();
Remains the question: Is more arguments than expected an error? Well, I usually ignore unneccessary arguments, but this too depends on the context. Another way I'm using (especially in constructor methods) is passing hashes and then check for existing keys. So in general I'd say it depends on the context, but I wouldn't let an object kill the entire program.
Regards,
-octo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What Are The Rules For Subs And Modules When Fed Wrong Input
by dimmesdale (Friar) on Jul 21, 2002 at 14:25 UTC | |
|
Re: Re: What Are The Rules For Subs And Modules When Fed Wrong Input
by lofichurch (Beadle) on Jul 22, 2002 at 19:42 UTC |