Error Message Design
The following guidelines help ensure that your exception messages are meaningful and correctly formatted.
Do provide a rich and meaningful message text targeted at the developer when throwing an exception. The message should explain the cause of the exception and clearly describe what needs to be done to avoid the exception.
The message should be targeted at the developer if you are building a library.
Do ensure that exception messages are grammatically correct. Top-level exception handlers may show the exception message to application end users.
Do ensure that each sentence of the message text ends with a period ("."). This way code that displays exception messages to the user does not have to handle the case where a developer forgot the final period, which is relatively cumbersome and expensive.
Avoid question marks ("?") and exclamation points ("!") in exception messages.
Do not disclose security-sensitive information in exception messages without demanding appropriate permissions.
For more information about secure library design, see Writing Secure Class Libraries.
Consider localizing the exception messages thrown by your components if you expect your components to be used by developers speaking different languages.
For more information about developing localizable code, see Localization.
Portions Copyright 2005 Microsoft Corporation. All rights reserved.
Portions Copyright Addison-Wesley Corporation. All rights reserved.
For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.