1908
Potential Mitigations
Phase: Implementation
For every exception block add code that handles the specific exception in the way intended by
the application.
Demonstrative Examples
Example 1:
In the following Java example, the code catches an ArithmeticException.
Example Language: Java (Bad)
public class Main {
public static void main(String[] args) {
int a = 1;
int b = 0;
int c = 0;
try {
c = a / b;
} catch(ArithmeticException ae) {
}
}
}
Since the exception block is empty, no action is taken.
In the code below the exception has been logged and the bad execution has been handled in the
desired way allowing the program to continue in an expected way.
Example Language: Java (Good)
public class Main {
public static void main(String[] args) {
int a = 1;
int b = 0;
int c = 0;
try {
c = a / b;
} catch(ArithmeticException ae) {
log.error("Divided by zero detected, setting to -1.");
c = -1;
}
}
}
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 1129 CISQ Quality Measures (2016) - Reliability 1128 2440
MemberOf 1412 Comprehensive Categorization: Poor Coding Practices 1400 2538
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
OMG ASCRM ASCRMRLB-