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;
}
검사 구성: