TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  StrictException1Checked automatically with code checker

Synopsis:A catch statement should never catch throwable since it includes errors
Language:Java
Severity Level:1
Category:StrictException


Description:
This is dangerous because it casts too wide a net; it can catch things like OutOfMemoryError.
public class Foo {
 public void bar() {
  try {
   // do something
  } catch (Throwable th) {  //Should not catch throwable
   th.printStackTrace();
  }
 }
}