The best error message is no error message. But error messages can not always be prevented.
Error messages should be correct and helpful. It is recommended to use systematic methods for predicting all the errors that may occur in a software system and make sure each error generates a correct error message. Thorough testing is necessary because there may be unpredicted errors which fail to generate appropriate error messages.
An error message should explain the nature and origin of the error. Avoid reference to software line numbers or addresses that are useless to the user who has no access to the source code.
A short error message may be supplemented with a Help button that gives a more detailed explanation of the error and possible remedies for solving the problem.
An error message may be followed by a menu of choices for how to recover from the situation. Assume, for example, that the user wants to save a file to a removable disk, and the system gives this error message: "Error writing file E:\hello.txt: Disk defective or not formatted." In this situation the system may present the user to the following choices:
- Cancel write operation
- Replace disk and retry
- Format disk
- Save file elsewhere
Redundant error messages should be avoided. If a particular situation generates a hundred errors of the same type then the system should not print a hundred identical error messages. If errors are signaled by a message box popping up then the system should make a single message box with multiple messages rather than multiple message boxes with one message each in case of multiple simultaneous errors.