I have a small Scala program that reads data from a data source. This data source is currently a CSV file, so it may contain data inconsistencies.
When implementing the repository template for my data, I implemented a method that returns an object by a specific field, which must be unique. However, I can not guarantee that it will really be unique, as in the .csv file, I can not ensure the quality of the data as I could in a real database.
Thus, the method checks whether there is one or zero object with the requested field value in the repository, and this is good. But I don't know Scala well (or Java, for that matter), and the Java exception hierarchy diagrams I found were not very useful. What would be a suitable throw exception if there are two objects with the same supposedly unique value. What should i use?
source
share