I have a method that reads data from a comma separated text file and constructs a list of entity objects, let's say customers.
So it reads for example,
Name
Age
Weight
Then I take these data objects and pass them to a business layer that saves them to a database. Now the data in this file might be invalid, so I'm trying to figure out the best error handling design. For example, the text file might have character data in the Age field.
Now my question is, should I throw an exception such as InvalidAgeException from the method reading the file data? And suppose there is length restriction on the Name field, so if the length is greater than max characters do I throw a NameTooLongException or just an InvalidNameException, or do I just accept it and wait until the business layer gets a hold of it and throw exceptions from there?
(If you can point me to a good resource that would be good too)