views:

99

answers:

8

I'm want to get an idea how I should handle end-user visible error messages in my web application.

  • How much information do you give in error messages?

  • Do you redirect all errors, regardless of type, to a common error page, or do you have a small set of pages (404, 403, all others)?

  • Do you give error codes that the user could reference/give to you that only you understand?

  • Do you give any technical details?

As I stated, my users are non-technical regular Joe folks.

+5  A: 

Display a nice error to the user, Log a detailed error for yourself.

madcolor
+1  A: 

I try to do the following:

  1. make sure you never run the risk of passwords or connection strings appearing in error messages.
  2. Make sure the errors get logged to a persistable medium. I prefer a database so that I can query by time range and other paramaters. I don't log 404s.
  3. If the application is an internal app that does not need to be pretty, it may be ok to have the error info on the page. Even if you are logging this stuff, it is nice to be able to have your users email you a screen shot or copy/paste.
  4. If 3 seems distasteful, have some error info written as HTML comments. Then you can at least see the info by viewing source.
Matt Wrock
+1 for considering security!
TrueWill
+1  A: 

In general I try to give users as much information needed to help them solve their problems themselves. For example, in the case of a 404, you might want to let them know to double check that the URL they are looking for is correct.

They obviously wont need stack traces, and the like, but it will make sense for you to log that level of detail somewhere for diagnostics and debugging.

Alan
+1  A: 

for fatal errors, keep them short, so they can repeat them over the phone or e-mail: can't connect to database, etc.

for non-fatal errors, describe the condition fully: Error, can not save the invoice without an invoice date.

I also always log everything, the parameters to the function and any internal values that may be of use.

KM
A: 

I try to show users enough information that they know it's an issue they need to tell someone about, but try to avoid showing them so much it scares them!

If possible the error message should tell them what just failed e.g did their save just fail, or has it saved fine, but the refresh of the screen afterwards had an issue. Extra error information (e.g. stack traces) should be logged somewhere where you can get at it without the user having to send it to you.

Ruffles
A: 

When it comes to displaying errors for the end user, I find it a good practise to display a errorcode (so me and administrators know what error it is) and a typical "ops something went wrong, please contact an administrator"

It can be good to give a bit more information for common errors that could be the cause of the users actions. But usually too much information can scare or confuse the user.

Jonas B
A: 

Your web application's error messages should always (at least) be the answers these 3 questions (in that order):

  1. What happened?

  2. Why did it happen?

  3. What can be done about it?

I have used it for many years, originally from Apple's "Human Interface Guidelines: The Apple Desktop Interface". Newer version. Microsoft has similar guidelines.

This also makes it easy to write them - this structured approach makes it faster to write them as one can just answer the questions.

The error messages should also be specific. Any information that the web application know about and that the user may need to resolve the problem should be in the error message. The (infamous) error message "An error happend." is simply not acceptable.

Optional: more technical information that the user may not understand can be placed at the end. But it should be marked as such.

Peter Mortensen
A: 

None, just show give a reference number so user can give it to you, and you can check the details from the application logs (obviously you need to keep a copy of error logs).

dr. evil