How to write good error messages

An anonymous javaBlogger posted about crummy error messages in many common frameworks today. His complaint was with messages like this:

And proprosed changing them to include the offending input:

I would say go even further. Explain exactly why the input failed and what input is expected. For example:

Put your self in the role of the user who is just starting out with your framework. And by "user" it could be a programmer extending your framework, a teammate using your interface, or Joe User trying to use your GreaseMonkey script. Imagine what would be helpful for someone who knows absolutely nothing about the inner workings of your program, and what sort of information would be helpful when things go wrong. Graham wrote "Empathy is probably the single most important difference between a good hacker and a great one." So have some empathy, and spend a little more time on those error messages.

Back to the front page