We have a Create operation that runs validation on the entity that was passed in. If this entity is not valid, what exception should be thrown?
Initially, we were going to throw ApplicationException, but after some research it seems this is incorrect: (from an article on MSDN):
X DO NOT throw or derive from ApplicationException
.
Should we create a custom Exception and inherit from ApplicationException
?
Is there an Exception that exists in the .NET framework that we should be using?
Or maybe, should we not throw an exception at all?
I am not sure...
Some more detail:
In this specific case, the Create method create an address change request. Business rules state that there can only be one address change request at a time. The validation error can come from one of two scenarios:
A property of the entity is not set, or is set to an incorrect value
An address change request already exists.