Suppose you want to throw Exception like this:
‘Project with the provided ID cannot be assigned.’
and you don’t want to write your custom Exception class. What predefined Exception class would you use for this?
(I’m talking about all classes inheriting from Exception)
Why can’t the project be assigned? Is it because the ID provided (presumably as an argument) is inappropriate? If so, it should be an
ArgumentException. If it’s because the project’s state is inappropriate for assignment, thenInvalidOperationExceptionwould be better. If it’s something else, please give more details.Of course, there may not be anything really suitable. Sometimes the best approach really is to write your own exception class.