Hello,

I'm designing an all encompassing error handling scheme for Perl-based web applications, and I'd like some feedback on it.

I wanted a solution would handle every kind of error handling: errors from third part modules and errors from our own. Errors we expected might happen and errors we didn't. Errors we want to let the user know about in some form, and errors we don't. Errors we'd like to get e-mail about and errors we don't. Errors we like to review later, and those that are transient.

I'm fairly satisfied with what I came up with, but I have nagging reservations about it-- a sense that "this must have been solved before"...or "there is still a better way".

Error Handling Specification

developed by Mark Stosberg for Summersault

Goals

Some details

Discussion points

A Phase 2 idea

(this doesn't need a finished spec now)

References

-mark

Replies are listed 'Best First'.
Re: Proposal for Uber Error Handling Architecture
by adrianh (Chancellor) on Mar 24, 2003 at 17:24 UTC

    Couple of random thoughts:

    • Take a look at Log::Log4perl. This can do a lot of what you need.
    • A method I've found useful is to use something like Data::UUID to create a unique ID for every message logged. If it's a user error you can get them to copy 'n' paste the ID and you know exactly what they saw.
    • I may be wrong, but "notices" seem out of place with the other types. It's UI information, not logging information.
    • I tend to like to log to one place. You can always post-process the messages into another format if you need to. By all means e-mail (or whatever) as well - but having once place you know the messages will be makes things simpler. For example, recovering from a failed logging method is easier. If your e-mail logger fails you only have to log that fact, you don't have to worry about recovering the original message and logging that as well.
Re: Proposal for Uber Error Handling Architecture
by hardburn (Abbot) on Mar 24, 2003 at 15:34 UTC

    See also: Error

    ----
    Reinvent a rounder wheel.

    Note: All code is untested, unless otherwise stated

Re: Proposal for Uber Error Handling Architecture
by valdez (Monsignor) on Mar 24, 2003 at 18:53 UTC
Re: Proposal for Uber Error Handling Architecture
by kudra (Vicar) on Mar 24, 2003 at 23:00 UTC
    Tools::Log might be of interest; it provides a framework for common error handling without specifying what you might want to do with your errors (that part is left for you to handle within the context of the application).
Re: Proposal for Uber Error Handling Architecture
by Solo (Deacon) on Mar 25, 2003 at 12:08 UTC
    Stop everything and get Log::Log4perl! adrianh said it first, but not strongly enough for me. I cannot stress enough what a godsend this module is! Among other things, it already:
    • cleanly handles your email concerns
    • allows changing logging configurations on-the-fly (critical, since you seem to be dealing with web errors)
    • supports all the Log::Dispatch handlers
    • has a bazillion other cool or important features

    Check out the Perl.com article or Google it and see for yourself!

    Update: just a little formatting change

    --Solo

    --
    Who's scruffy lookin'?

      Thanks everyone for their replies. I hadn't heard of Log::Log4perl before, and it looks like an excellent solution...a very near match to what I had envisioned. It looks like I may need to handle returning errors to the user's browser seperately, but that may be a Good Thing anyway.

      I'm also now considering just logging everything to STDERR now for performance and consistency, and possibly running a cron job at off-peak hours to parse the logs for anything I might want to stuff in a database for easier review and handling.

      -mark

        I've done it that way before. I cron a little script that checks the error_log for anything interesting and mails it to me. "Interesting" is defined with simple regexes. This works well and keeps you from getting lots of little e-mails when something goes wrong.