Timeline for Is it ok to derive from System.ArgumentException?
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 31, 2019 at 16:30 | review | Close votes | |||
Apr 1, 2019 at 5:36 | |||||
Oct 14, 2012 at 18:56 | vote | accept | Klitos Kyriacou | ||
Oct 12, 2012 at 11:23 | comment | added | Şafak Gür |
If the supplied parameters are not valid, the method is expected to throw an ArgumentException . You can perfectly derive from it to use in such cases. Deriving from SystemException doesn't make sense but you throw an ArgumentNullException if an argument is null or ArgumentOutOfRangeException if it's outside the acceptable range. They both are derived from ArgumentException . So throwing a custom exception which is not derived from ArgumentException in such cases is IMHO something that you shouldn't do. So I'd go with Botz3000's answer.
|
|
Oct 12, 2012 at 11:17 | answer | added | Botz3000 | timeline score: 41 | |
Oct 12, 2012 at 11:16 | answer | added | Trevor Pilley | timeline score: 4 | |
S Oct 12, 2012 at 11:14 | history | suggested | MMK | CC BY-SA 3.0 |
edited the text
|
Oct 12, 2012 at 11:14 | answer | added | dbattaglia | timeline score: 7 | |
Oct 12, 2012 at 11:12 | answer | added | Peter | timeline score: 2 | |
Oct 12, 2012 at 11:11 | review | Suggested edits | |||
S Oct 12, 2012 at 11:14 | |||||
Oct 12, 2012 at 11:11 | answer | added | Dennis Traub | timeline score: 5 | |
Oct 12, 2012 at 11:05 | history | asked | Klitos Kyriacou | CC BY-SA 3.0 |