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".
$self->error(msg=>'Something Bad Happened', level=>'error')
| name | official syslog desc. | our use | default action |
|---|---|---|---|
| debug | info normally of use only when debugging a program. | debugging output when $CFG{DEBUG} or $DEBUG is set to a true value. Using this instead of a simple "warn" or "carp" allows us easily and centrally turn all debugging on or off. | send to Apache log-- there's no need preserve this in the database. (no browser output) |
| info | Informational messages. | Used when application is asked to log more about what it's doing. No current applications. | send to Apache log-- not used for browser-based feedback. |
| notice | Non- error conditions that should possibly be handled specially. | Our default log level for messages sent to the user for situations that are exceptional but expected to occur sometimes such as "Insufficient Information" or "Some fields are missing or invalid" | No logging. |
| warning | warning messages. | We use this to log our own warnings as well as those caught by installing a signal handle for the real "warn". | Logged to Postgres-- We probably want to review this later and find out what caused them and make them go away. We include a stack trace for the last 4 callers as well as $!. Nothing is sent to the browser since warn statements usually don't do that and they wouldn't make sense to end users. |
| error | Error. | Something is actually wrong that we are sure about, such as function returning an unexpected output, receiving unexpected input, etc | Logged to Postgres with a stack trace and a message to the user with some fixed text in addition to the "message", to the effect of "consider contacting someone" |
| critical | critical conditions, e.g., hard device failure | Used to trap "die" as called by legacy or third-party software, calls within 'eval' statements are exceptions. | Action is as for "error", with the user text changed to "critical error". Email is sent |
| alert | Should be corrected immediately | Our notation for "if we get here, something is really wrong". | Logged to Postgres, "Critical error" sent to browser, e-mail sent. |
| emergency | panic condition | No use at this time-- this domain of our monitoring software, not our application software. | n/a |
-mark
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Proposal for Uber Error Handling Architecture
by adrianh (Chancellor) on Mar 24, 2003 at 17:24 UTC | |
|
Re: Proposal for Uber Error Handling Architecture
by hardburn (Abbot) on Mar 24, 2003 at 15:34 UTC | |
|
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 | |
|
Re: Proposal for Uber Error Handling Architecture
by Solo (Deacon) on Mar 25, 2003 at 12:08 UTC | |
by markjugg (Curate) on Mar 25, 2003 at 15:04 UTC | |
by perrin (Chancellor) on Mar 25, 2003 at 22:53 UTC |