I have a standalone application that does data checking of flat files before they are imported into a SQL database.
In a context like this, does it make sense to throw a System.Data.ConstraintException
? (The example is contrived.)
if(_keys.ContainsKey(key))
{
throw new ConstraintException(string.Format("Uniqueness violated! " +
"This unique combination of '{0}' already found on line {1}",
GetUniquenessColumnList(), _keys[key] ));
}
ConstraintException's documentation states that it "represents the exception that is thrown when attempting an action that violates a constraint."
Is there a problem with using the built-in exception this way? Is there a better one to use? Should I build my own, even though this exception seems tailor-made to my situation?