in reply to Error Handling and Logging for Object-Oriented Perl Application

Best practice logging is simply to use Log::Dispatch::Config. It will take care of all your logging needs, and just quite simply be the right way to do logging. Trust me on this one.

Best practice error handling is to use exceptions. Otherwise you end up passing return codes back up the stack, and with 30 or 40 classes that's going to get messy. Try using exceptions by throwing objects - good modules to use for this are Exception::Class and Error (though beware of the try/catch syntax offered by the latter - it's tempting but uses closures so can lead to memory leaks if you don't know what you're doing). Also I recommend a $SIG{__DIE__} handler for catching non-object exceptions (i.e. when someone just does "die 'Foo'" in their module), this way all your exceptions can provide useful backtrace information.

And yes, I have a talk on this for the upcoming Perl Conference. ;-)

  • Comment on Re: Error Handling and Logging for Object-Oriented Perl Application