Best Practices for Exception Handling
Subject:   Ultimately, what to do with the rascals
Date:   2003-11-25 16:50:19
From:   xyphrnld0x
Excellent article!

Joshua asked (and I can't seem to reply directly using the [Reply] links) about handling and reporting exceptions. Suggestions:

For the programmer: Get it to the programmer! On a web site, this is an e-mail message to a mailbox that is actively observed by support. We've mailed it directly to the dev team in some cases.

For the user: Avoid throwing the stack trace in the user's face. Perhaps your custom exceptions will have two messages: One for the programmer and one for the user. For that web application described above, we display a generic "Sorry" message with a unique "user error number" that corresponds to the subject in the e-mail sent to development.

For the web app administrator: Yes, we actually logged the exception. Our custom exceptions do their own logging, including stack trace, during construction. Hmmm. Does anyone ever read those logs...? If you were receiving daily e-mail from your application, screaming "I'M BROKEN!" you could live without logged stack-traces, too.