Inspectopedia Help

'catch' block may ignore exception

Reports catch blocks that are empty or may ignore an exception.

While occasionally intended, empty catch blocks may complicate debugging. Also, ignoring a catch parameter might be wrong.

The inspection won't report any catch parameters named ignore, ignored, or _.

You can use the quick-fix to change the exception name to _.

Example:

try { throwingMethod() } catch (ex: IOException) { }

After the quick-fix is applied:

try { throwingMethod() } catch (_: IOException) { }

Use the Do not warn when 'catch' block contains a comment option to ignore catch blocks with comments.

Inspection options

Option

Type

Default

Do not warn when 'catch' block contains a comment

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023