Reputation: 11871
I have a method that takes three parameters (3D points). I want to throw an exception if the points are colinear. The obvious exception to me is ArgumentException
, but the best practise with this is to include the param name in the constructor. In my case it's the combination of all three params which is the invalid input - so the best practise isn't going to work (and I think my code analysis will moan like hell).
So do I use ArgumentException
here or something like InvalidOperationException
because there's more than one parameter causing the problem?
Upvotes: 8
Views: 1699
Reputation: 8152
Try creating your own Exception type, deriving from ArgumentException
. In that class you can store all three parameters.
Upvotes: 3
Reputation: 66573
I think both are fine.
If you choose to use ArgumentException
, you can use the name of any one parameter. Personally I would use the name of the last parameter. After all, if the points are collinear, you need to change only one and then all the parameters are fine. :-)
Upvotes: 2