I parse an XML file to load data and when I have an attribute that has an unrecognized value I throw an InvalidDataException
. Is this the correct one or is there a better/more descriptive one?
That exception suggests that it's an error in the format of the file itself, like an error in the encoding of the characters. An XmlException would be a better fit.
Consider throwing an ApplicationException instead, as it's not really an error in the XML format, but rather something that the XML contains that your application does not accept.