mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
31 lines
1.1 KiB
HTML
31 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports <code>catch</code> blocks with parameters that are more generic than the
|
|
exception thrown by the corresponding <code>try</code> block.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
try {
|
|
File file = new File(pathToFile);
|
|
return file.getAbsolutePath();
|
|
} catch (Exception ex) { // warning: 'catch' of 'Exception' is too broad, masking exceptions 'RuntimeException'
|
|
return defaultFilePath;
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
try {
|
|
File file = new File(pathToFile);
|
|
return file.getAbsolutePath();
|
|
} catch (RuntimeException ex) {
|
|
return defaultFilePath;
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>Configure the inspection:</p>
|
|
<ul>
|
|
<li>Use the <b>Only warn on RuntimeException, Exception, Error or Throwable</b> option to have this inspection warn only on the most generic exceptions.</li>
|
|
<li>Use the <b>Ignore exceptions which hide others but are themselves thrown</b> option to ignore any exceptions that hide other exceptions but
|
|
still may be thrown and thus are technically not overly broad.</li>
|
|
</ul>
|
|
</body>
|
|
</html> |