[Chicago-talk] Errors. And the reporting thereof.

Paul Baker pbaker at where2getit.com
Fri Nov 14 13:42:37 CST 2003

Jim Thomason wrote:
> Which brings us to some of the caveats that will
> hinder  the "relatively painlessly" part.
> 1) We have to be able to roll it out piece-meal into
> the system. Anything that would require an immediate
> and total re-write of everything to handle something
> new really isn't appropriate.
> 2) It always has to report the correct error back.
> (duh, but I'll address that in a moment).
> 3) It can't break any of the existing code. Virtually
> all of the error handling is done by returning
> something true upon success and undef upon failure.
> Easy, right?

Well that depends. I have one question, because which I wasn't sure I know what the goal of the extra error reporting is meant to meet. Basically my question is, do you want the more "verbose" errors so that 1) foo can behave differently based on what error happened in bar. 2) Or will foo always behave the same when bar returns undef no matter what error occured?

To further explain, foo calls bar. bar has an error and returns undef. Now with bar modifed with the better error message support, which would you like to be the end result of this better error message?

1) foo checks the error message to see which error occured. foo then does x, y, or z depending on which actual error occured.

2) foo continues to do as it is currently coded to when it receives undef from bar and it really doesn't care what actual error happened. But you (the person, not the code) want to find out what the real error was so you can fix it after the fact.

So basically which of these do you want. If you want 1 you want some real sort of error handling. If all you really want is 2, then what you need is error logging.

If you want 1, I leave it in the hands of the other people on this list. If you want 2, then I suggest you check out the Log::Log4perl module on CPAN. It is kick ass and it is very easy to add something to your code base in piece mail. In fact I am doing this very same thing to my company's very large code base. As I go into each module for normal reasons (add a new feature, fix some bug) I at the same time remove the currently existing crappy error handling code (written by me) and replace it with Log::Log4perl calls. It's very nice and I have no regrets as of yet. Log::Log4perl is very cool because you can easily modify the verbosity of your error reporting WHILE AN APPLICATION IS STILL RUNNING!! No need to shut it down, change something and restart it. How cool is that?!

So yeah, if really what you need is just good ol' error logging, I can help you out with that.

Paul Baker

More information about the Chicago-talk mailing list