I’m sorry if this has been asked before – but I couldn’t find a similar question.
I have an object which represents a query and an ordering specification for the results. I would like the semantics to be that you can specify null for the query (i.e. return all results), that you can specify null for the order (i.e. return results in any order), but you cannot specify null for both (because then why are you using the query engine…)
So, ArgumentException, ArgumentNullException and ArgumentOutOfRangeException didn’t seem right because it’s not one argument – and their doc comments all refer to the singular.
Any pointers?
Thanks.
If this is simply to help developers when using your method then go for a standard
InvalidOperationExceptionorArgumentException, with a helpful message, and leave it at that. Put time into more important areas.If this is going to be driven from the UI or some other process, then you shouldn’t ever need to hit the exception as it will be better to validate the input. If you do input validation inside the method, then perhaps consider a custom
InvalidInputException, again with a message (I’m not going to start the “are input errors exceptions?” debate…).Don’t worry too much about the specifics of the documentation. So long as the usage follows some measure of common sense, your colleagues will be able to understand what is going on.