mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
55 lines
2.1 KiB
HTML
55 lines
2.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports <code>catch</code> blocks that are empty or may ignore an exception.
|
|
<p>While occasionally intended, empty <code>catch</code> blocks may complicate debugging.
|
|
Also, ignoring a <code>catch</code> parameter might be wrong.
|
|
Finally, the static code analyzer reports if it detects that a <code>catch</code> block may silently ignore important VM
|
|
exceptions like <code>NullPointerException</code>. Ignoring such an exception
|
|
(without logging or rethrowing it) may hide a bug.</p>
|
|
|
|
<p>
|
|
The inspection won't report any <code>catch</code> parameters named <code>ignore</code> or <code>ignored</code>.
|
|
Conversely, the inspection will warn you about any <code>catch</code> parameters named <code>ignore</code> or <code>ignored</code> that are actually in use.
|
|
Additionally, the inspection won't report <code>catch</code> parameters inside test sources named <code>expected</code> or <code>ok</code>.
|
|
</p>
|
|
<p>
|
|
You can use a quick-fix to change the exception name to <code>ignored</code>.
|
|
For empty <b>catch</b> blocks, an additional quick-fix to generate the <b>catch</b> body is suggested.
|
|
You can modify the "Catch Statement Body" template on the Code tab in
|
|
<a href="settings://fileTemplates">Settings | Editor | File and Code Templates</a>.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
try {
|
|
throwingMethod();
|
|
} catch (IOException ex) {
|
|
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
try {
|
|
System.out.println(System.in.read());
|
|
} catch (IOException ignored) {
|
|
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>Configure the inspection:</p>
|
|
<ul>
|
|
<li>
|
|
Use the <b>Do not warn when 'catch' block contains a comment</b> option to ignore <code>catch</code> blocks with comments.
|
|
</li>
|
|
<li>
|
|
Use the <b>Do not warn when 'catch' block is not empty</b> option to ignore <code>catch</code> blocks that contain
|
|
statements or comments inside, while the variable itself is not used.
|
|
</li>
|
|
<li>
|
|
Use the <b>Do not warn when exception named 'ignore(d)' is not actually ignored</b> option to ignore
|
|
variables named <code>ignored</code> if they are in use.
|
|
</li>
|
|
</ul>
|
|
|
|
<p><small>New in 2018.1</small></p>
|
|
</body>
|
|
</html> |