robartes has asked for the wisdom of the Perl Monks concerning the following question:
So, I'm now making this behaviour configurable. Something like (for an OO inspired module):
This allows for exceptions (everything is an exception) or recoverable / non recoverable warnings (non recoverable return undef), depending on the (user settable) value of an instance attribute.package Foo; # ... do_tricky_stuff or $self->_complain("Tricky stuff failed"); do_unrecoverable_stuff or return $self->_complain("Grave problem"); # ... sub _complain { my $self=shift; my $msg=shift; croak($msg) if $self->fatal_warnings(); carp($msg); return undef; }
I'm looking for some input on how other people handle this.
CU
Robartes-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Error reporting in modules
by merlyn (Sage) on Apr 15, 2003 at 12:33 UTC | |
|
Re: Error reporting in modules
by Abigail-II (Bishop) on Apr 15, 2003 at 12:36 UTC | |
|
Re: Error reporting in modules
by l2kashe (Deacon) on Apr 15, 2003 at 14:05 UTC | |
|
Re: Error reporting in modules
by cLive ;-) (Prior) on Apr 15, 2003 at 17:09 UTC |