All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.squidjava.rules.squid.S1181.html Maven / Gradle / Ivy

Throwable is the superclass of all errors and exceptions in Java. Error is the superclass of all errors which are not meant to be caught by applications.

Catching either Throwable or Error will also catch OutOfMemoryError or InternalError from which an application should not attempt to recover.

Only Exception and its subclasses should be caught.

The following code snippet illustrates this rule:

try { /* ... */ } catch (Throwable t) { /* ... */ }    // Non-Compliant
try { /* ... */ } catch (Error e) { /* ... */ }        // Non-Compliant
try { /* ... */ } catch (Exception e) { /* ... */ }    // Compliant




© 2015 - 2025 Weber Informatics LLC | Privacy Policy