The exact Error is: "There is a more general exception, 'java.lang.exception' in the throws list already"
I have a method like so:
public String myMethod() throws FileNotFoundException, IOException, Exception {
try{
// DO STUFF
}catch(FileNotFoundException e){
// DO STUFF
throw new FileNotFoundException("custom message", e);
}catch(IOException e){
// DO STUFF
throw new IOException("custom message", e);
}catch(Exception e){
throw new Exception("custom message", e);
}
return myString;
}
Intellij tells me that the first two are redundant because I have the more general Exception
at the end, is that the case?
Will the method throw an Exception
even if I explicitly throw an IOException
?
Or is it the case that generic Exceptions will be thrown up the stack anyway, so I don't even need Exception
on the end ?