Thursday, April 26, 2007

On handling errors...

The 3 error types I'm dealing with all the time: bad data, resources that aren't available or invalid and surprises.

Validate data coming into the application whether it be from people, web services or file system imports. Reject everything that doesn't match what you're expecting. But don't forget to tell the user what went wrong! (Where you do the validation is another story - the short answer: on the server.)

Catch errors you can reasonably recover from. File not founds, access denieds, timeouts, etc. Bring the application back to a valid state, help the user correct the error and continue.

Anything else has to go through a generic error handler. "An application error has occurred. Please contact technical support and refer to error number: nnnn."

No comments: