c# - What exception should be thrown when validation fails? -


we have create operation runs validation on entity passed in. if entity not valid, exception should thrown?

initially, going throw applicationexception, after research seems incorrect: (from article on msdn):

x not throw or derive applicationexception.

should create custom exception , inherit applicationexception?

is there exception exists in .net framework should using?

or maybe, should not throw exception @ all?

i not sure...

some more detail:

in specific case, create method create address change request. business rules state there can 1 address change request @ time. validation error can come 1 of 2 scenarios:

  1. a property of entity not set, or set incorrect value

  2. an address change request exists.

you should throw invalidargumentexception


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -