Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Unchecked exception classes such as Error and its subclasses are not subject to compile-time checking not only because it is tedious to account for all exceptional conditions, but also because recovery is generally difficult. However, even when recovery is impossible, the Java Virtual Machine (JVM) allows a graceful exit and a chance to at least log the error. This is made possible by using a try-catch block that catches Throwable. Also, when code must avoid leaking potentially sensitive information, catching Throwable is permitted. In all other cases, catching Throwable is not recommended. Where cleanup operations such as releasing system resources are possible, code should use a finally block within which the resources should be are released or should use a try-with-resources statement.

...