Handling server errors gracefully and displaying a friendly message to users is often overlooked. Google doesn’t, and displays a more or less understandable message to its users. Including funny artwork of a broken robot.
The three important rules for handling server errors
Note that these rules not only apply to server errors, but any kind of error.
If possible in any way, try to prevent errors. Re-direct moved content to its new location. Catch exceptions. Monitor your application. Test, test, test.
There will always be errors that you can’t prevent. If this happens make sure you handle it gracefully. Make clear in plain text English that something went wrong and what the user can do to continue doing what he wants to do.
When handling errors gracefully and displaying a nice error message to your users, make sure that you keep track of what happened. Log application exceptions. Save your server logs. Pretend you’re an FAA officer researching a plane crash to make sure the same crash reason won’t happen again.