SPUG: Advice on sub return-code policies?
brianwisti at yahoo.com
Thu Oct 5 11:03:28 PDT 2006
Tim Maher 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".
> They won't be writing /everything/ in the OO style, so encapsulating
> the error codes within objects isn't an attractive choice.
> Any ideas on how they can comply with their policy without undermining
> their ability to do normal things, like chain functions together (as
> in reverse sort keys)?
> An "out-of-band" delivery mechanism would seem to be needed, but it
> would have to be sophisticated enough to be usable with multi-
> threaded apps, and no too inefficient. Are there any CPAN modules
> that can help?
> What advice would you offer to a client like this?
I am curious about why they want a standardized error code returned from
every function. I think I know why they they think they want it, but
maybe there's an easier way to get what they really want without doing
it the way they think they want it done. I think.
My first thought would be to incorporate a __DIE__ handler and parse the
error code from the input to &die. I don't know how efficient or
thread-safe that solution is, though.
More information about the spug-list