Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Exceptions and Return Codes

by merlyn (Sage)
on Jun 29, 2001 at 17:45 UTC ( #92608=note: print w/replies, xml ) Need Help??


in reply to Exceptions and Return Codes

If a failure is a "normal" thing, a special return value is fine.

If a failure is an "exceptional" thing, I'd prefer a death that I can catch.

If extra information needs to be provided, I'd prefer a package-specific global, or (using recent Perl exceptions that can handle die $object), a death object which can be queried.

So there's no one "right answer". It really depends on how frequent and how complex the failure can get.

And as long as I'm on the soapbox, the wrong answer is "put it into $@", as some of the IO::* does. That's reserved for an eval failure, Graham. Usurping that was a bad idea. Bleh.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Exceptions and Return Codes
by agoth (Chaplain) on Jun 29, 2001 at 18:06 UTC
    AAAAAAAAAAAAArgh, but thank you,

    That last one has been bugging me all week, I've been wading through some old IO::Socket and IO::Select code and $@ was being checked a few times with no eval's or do's in sight
    And no mention in the perldoc that i could find either, thats one niggle less at least...

    cheers

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://92608]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2019-12-12 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?