Here are some pattern candidates for writing error messages, seeking user confirmation etc. -- AamodSane
"There shouldn't be any error messages because there should never be any errors!" -- PointyHairedBoss
Confirmation or undo of data losing operations
Where possible, allow user to recover from errors. For example, if you delete a file in a file browser, you should be able to undo the delete, always.
The Windows Explorer is a good example of how not to do it. It asks you "should I delete" often, and you get desensitized to it. Normally you can recover from a delete. Then, it introduces situations where you cannot undo the delete, and the warning message looks similar enough that you don't bother to read it.
Tell me how to fix it
There is little point in merely informing a user about an error, if they cannot fix it. For example, in a compiler, when you find an illegal identifier, don't just say "illegal identifier %%aa". Try something like "%%aa is illegal. Legal identifiers are [a-zA-Z_][a-zA-Z_0-9]*" (if your audience understands regex syntax). If necessary, add a help button that contains the long explanation. (also nice: linkers which, instead of merely complaining "duplicate symbol" in one object, actually give you all objects containing the offending symbol.)
Tell me what went wrong
In the above, at least "illegal identifier %%aa" outputs the identifier. Imagine how much fun it is to be sending stuff over sockets to another program, with only the dodgiest of protocol specs, to only get "Checksum Error" again and again until hours later you realize the bytews were in the wrong order. Now imagine getting "Checksum Error. Expected: 0x2ABC Got: 0xBC2A".
Of course, in this form it still doesn't do much for the end user.
Not that this ever happened to me...
No mysterious messages
Present error messages that the user can do something about.
No cascading messages
Sometimes, the combination of your errors, the windowing system, and other environments lead to a series of error messages one after another. On Windows, this happens usually with applications that require the user to select files. If there is no disk space, the file is in use, the wrong kind of file is chosen, you have to jump through error hoops.
When possible, present the user with alternatives that your application will not founder on.