Inspectopedia
 
2024.3

'instanceof' on 'catch' parameter

Warning
New
Last modified: 03 December 2024

Reports cases in which an instanceof expression is used for testing the type of a parameter in a catch block.

Testing the type of catch parameters is usually better done by having separate catch blocks instead of using instanceof.

Example: