Consider the following example: as part of the configuration of my program, the user supplies an XML file, which should essentially describe an acyclic graph, but my program finds a graph at startup. This is a critical error; the program cannot continue. Which exception should be thrown?
Other examples include trying to upload a file in a specific format (for example, JPEG), but encountering an error along the way; or receive some data over the network from another third-party program, which should be correct, but is not.
Essentially, you parse some kind of data stream and find an error in it, which should not be, which means that the program cannot continue as expected. What is the correct type of exception to throw here?
(Note. This should not be an exception to Argument XXX , as this data is not passed as a parameter to the method).
Vilx- source
share