SPUG: Advice on sub return-code policies?

jerry gay jerry.gay at gmail.com
Wed Oct 4 15:28:20 PDT 2006


On 10/4/06, Tim Maher <tim at consultix-inc.com> wrote:
> The client I'm working with this week wants to develop a large
> enterprise application in Perl using a special policy: every sub needs
> to return a standardized "error code".
>
*every* sub?
C<sub wanted { ... }> destined for use with File::Find?
C<sort> subroutines?
a sub which returns the value of C<index>?

this is one place where perl falls down, as there is no standard error
reporting mechanism. since there is more than one way to do it, many
module authors choose to do it differently. this includes many
different ways in core modules, and even core perl ops, as illustrated
above.

One Way To Do It is very hard to implement in perl, especially when
you're using modules written by other authors.

perhaps this can be abstracted a bit. suggest a well-defined set of
error reporting mechanisms, and standard sets of error codes (perhaps
better still one set across reporting mechanisms.) if there's an error
reporting framework, enterprise component authors can specify via
documentation which error mechanisms they employ, and component users
will have a clear idea of what's required to process component errors.

~jerry


More information about the spug-list mailing list