The following exception types are too general to provide sufficient information to the user:
Throw Specific Exceptions
The following table shows parameters and which exceptions to throw when you validate the parameter, including the value parameter in the set accessor of a property:
Parameter Description Exception null
referenceSystem.ArgumentNullException Outside the allowed range of values (such as an index for a collection or list) System.ArgumentOutOfRangeException Invalid enum
valueSystem.ComponentModel.InvalidEnumArgumentException Contains a format that does not meet the parameter specifications of a method (such as the format string for ToString(String)
)System.FormatException Otherwise invalid System.ArgumentException
This is just a spot to keep miscellaneous links. It also shows you what a geek I am.
Friday, March 30, 2018
Microsoft guidance on throwing exceptions
The rest of this post is a quote from this article at https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2201-do-not-raise-reserved-exception-types: