dash2 has asked for the wisdom of the Perl Monks concerning the following question:
So my question is, what is a nice way to handle "interesting" errors? I can think of a few:
1) Have failure return true (with an error message) and success false. Elegant, but counter-intuitive.
2) Have the subroutine/method return two values: success/failure, and an optional error message. Straightforward, but that extra value is going to waste space most of the time, and it's a bore to write your method calls always to expect two values.
3) Return true/false as normal for success/failure, and write to an object variable for the error message: e.g.
$success = $domain->do_whois() or print "Failed:". $domain->{whois_error};
I guess this is what the DBI module does. Perhaps this is best?
Opinions would be interesting. TMTOWDI and all that, of course, but I'd like to hear some views on the right way in particular situations.
Dave