http://www.perlmonks.org?node_id=595313

theguvnor has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing some in-house modules that will never see the light of CPAN, but still would like opinions:

What are your preferences for handling errors within your OO modules? I usually just die when starting development, but switch over to setting an error attribute in the object and returning (undef)... the philosophy being that the caller (me) should have the freedom to hang himself if he declines to check return codes. This seems to be the way most of the modules on CPAN handle things, but I know some modules just die and trust that the caller will wrap methods in an eval {} if he really wants to trap errors/exceptions.

Opinions?

Update I should also clarify that I'm talking about failures in OO methods... so calling something like $message->save_to_db() would, the way I'm currently doing things, return undef on an error and the caller can inspect $message->error to find out why. What I really want is built-in Exceptions (this is about the only thing I like better about PHP over Perl) so I'm keen on what gaal promises about Perl 6 (please hurry, p6p!).

[Jon]