In have written a function which expects the caller to pass in a configuration file like XML. Then I parse this given file and extract something which i then return.In this function (at least) two bad things can happen:The given file does not exist or is not accessible in any wayWhile parsing/validating the file some unexpected content is foundThe first thing is clearly an IllegalArgumentException. I am however not sure what kind of exception the second case would be. Is that also an IllegalArgumentException because i expect (by documentation-contract) that the input is in a valid form? Or is it rather an IllegalStateException as the given parameter is formal correct but only after parsing I can't do any further steps as it would result in unwanted behaviour?Or is it even something else?
IllegalStateException vs. IllegalArgumentException
java;exceptions;exception handling;error handling
Neither.  As others have pointed out, it is clearly not an IllegalStateException.And better than IllegalArgument would be FileNotFoundException or ParseException, (or maybe XMLParseException) which exactly match your description of bad things 1 and 2.