A good error message has a surprising number of attributes. The most important attribute is that the error message must be necessary. The best error message is no error message at all. Your first choice should always be to prevent the problem in the first place. Your second choice should be to try to work around the problem without bothering the user. A good third choice is to notify the user in a way that doesn't require the user to respond, such as putting information on the status bar. See Chapter 23, "Unnecessary Message Boxes Are Pure Evil" for a detailed discussion of avoiding unnecessary error message boxes.
An error message must provide enough information so that the user can understand the problem and know what to do about it. Typically this means that the error message needs to provide:
Providing this information makes error messages complete and self-explanatory. However, providing all of this information does not necessarily mean that a good error message is long and involved. If you can present the user with the information in a single short sentence, by all means do so. Users don't want to read long error messages. Rather, the error message should be: