Error Messages Are for Users, Not Programmers

Have you ever used a program and come across a totally bizarre error message? For example, have you ever seen an error message like this one?

Of course, the event did happen, and the user is very puzzled by such a message. In fact, the user can do absolutely nothing in response to this error message except panic.

The problem with this error message is that it isn't intended for the user. Rather, it was intended for the programmer to debug a problem and unfortunately was left in the release version of the program. There are four ways to prevent this problem:

  • Use an assertion instead.
  • Use a TRACE statement instead.
  • Use a debug report instead.
  • If really necessary, use an error message that is conditionally compiled for only the debug build (that is, use #ifdef _DEBUG … #endif) like the TRACE and ASSERT macros.

This observation makes the converse of my conclusion in the last section true. Error messages are not assertions or TRACE statements and should also not be used as a substitute.

TIP
Don't use error messages as a substitute for assertions or TRACE statements.



Developing User Interfaces for Microsoft Windows
Developing User Interfaces for Microsoft Windows
ISBN: 0735605866
EAN: 2147483647
Year: 2005
Pages: 334

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net