try
块抛出的异常更通用的 catch
块。
示例:
try {
File file = new File(pathToFile);
return file.getAbsolutePath();
} catch (Exception ex) { // warning: 'catch' of 'Exception' is too broad, masking exceptions 'RuntimeException'
return defaultFilePath;
}
在应用快速修复后:
try {
File file = new File(pathToFile);
return file.getAbsolutePath();
} catch (RuntimeException ex) {
return defaultFilePath;
}
配置检查: