Scala
Scala : Error handling: catching NullPointerException
Classification
Overview
Catch exceptions of NullPointerException type is usually considered to be a bad practice.
Catch NullPointerException usually occurs in one of three cases:
- There was a null pointer dereference. The developer decided that it is easier to catch an exception than to solve the problem that caused it.
- Application deliberately throws
NullPointerExceptionto report an error. NullPointerExceptioncatcher is part of the mechanism of testing, in which the application is given incorrect data as an input.
Catching NullPointerException is acceptable only in the latter case.
LOW
DerScanner Severity Score
Check your Scala code for this vulnerability, free
Request a free pilot of DerScanner. We give you access and help with the first scan. It works in the cloud and on-premise.
Try it on your code, free
By submitting this form, I acknowledge that DerScanner may process my personal data I provided above for purposes explained above. More details about the processing.
