== Why is this an issue? Multiple catch blocks of the appropriate type should be used instead of catching a general exception, and then testing on the type. === Noncompliant code example [source,java] ---- try { /* ... */ } catch (Exception e) { if(e instanceof IOException) { /* ... */ } // Noncompliant if(e instanceof NullPointerException{ /* ... */ } // Noncompliant } ---- === Compliant solution [source,java] ---- try { /* ... */ } catch (IOException e) { /* ... */ } // Compliant } catch (NullPointerException e) { /* ... */ } // Compliant ---- == Resources * https://wiki.sei.cmu.edu/confluence/display/java/ERR51-J.+Prefer+user-defined+exceptions+over+more+general+exception+types[CERT, ERR51-J.] - Prefer user-defined exceptions over more general exception types ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) === Message Replace the usage of the "instanceof" operator by a catch block. ''' == Comments And Links (visible only on this page) === on 16 Aug 2013, 08:27:16 Freddy Mallet wrote: Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-292 endif::env-github,rspecator-view[]