catch
block with parameters that are more generic than the
exception thrown by the corresponding try
block.
Example:
try {
File file = new File(pathToFile);
return file.getAbsolutePath();
}
catch (Exception ex) { // warning: 'catch' of 'Exception' is too broad, masking exceptions 'RuntimeException'
return defaultFilePath;
}
After the quick-fix is applied:
try {
File file = new File(pathToFile);
return file.getAbsolutePath();
}
catch (RuntimeException ex) {
return defaultFilePath;
}
Configure the inspection: