All posts on this blog are provided "AS IS" with no warranties, and confer no rights.
All source code snippets are released under the Ms-PL license.
When a method may throw for more than one reason, the thoughtful programmer might ask “which exception should be thrown?”
Consider a method which performs argument validation, is cancelable, and also might throw based on the state of the object. What order should these validations occur so that the best exception is thrown? Here is my own answer to that question, as an in-order list of verifications that prioritize the exception types and reasons: