in reply to Handling errors occuring inside complex modules

The poor man's hack is using eval to do the error handling.

eval { die "Goodbye cruel world" }; warn "eval died with $@" if $@;

eval{}; if($@) {} probably is the most common practice, but is ugly and error prone.

Other alternatives include error-handling modules such as TryCatch or Error (be aware that Error and Moose conflict if you use Moose.)

Try them (and other modules too!) and use which one feels more comfortable.

Update: I had completely missed you mentioned eval...

Replies are listed 'Best First'.
Re^2: Handling errors occuring inside complex modules
by stvn (Monsignor) on Jan 19, 2010 at 02:01 UTC
    Other alternatives include error-handling modules such as TryCatch or Error (be aware that Error and Moose conflict if you use Moose.)

    Actually Error is no longer recommended, it even says so in the POD

    Using the "Error" module is no longer recommended due to the black-magical nature of its syntactic sugar, which often tends to break. Its maintainers have stopped actively writing code that uses it, and discourage people from doing so. See the "SEE ALSO" section below for better recommendations.
    I personally recommend Try::Tiny instead (and it plays well with Moose)

    -stvn