Helpful NullPointerExceptions without Java 14!

Exceptional is our solution for those pesky NullPointerExceptions which tell you on which line things went wrong and nothing more. With Exceptional a clear and helpful message explaining which value is null will accompany the NullPointerException. Over are the days staring at a chain of method calls trying to understand which step may have produced a null.

Install the FREE Exceptional IntelliJ IDEA plugin from Jetbrains marketplace
Click to install the FREE IntelliJ IDEA plugin from Jetbrains marketplace

Exceptional adds informative NullPointerExceptions to all versions of Java, starting from Java 5! Obtain useful information with the NullPointerException as shown in the screenshot below. No need to analyse or guess what went wrong, the explanation is right there.

The NullPointerException above was intentionally triggered to illustrate the benefits of Exceptional. The message of the NullPointerException clearly shows which value was null.
Exceptional generates helpful information to a NullPointerException, allowing you to solve the problem quickly.

The NullPointerException above was intentionally triggered to illustrate the benefits of Exceptional. The actual unit test case is the one shown below.

Perform a lookup for the obviously missing “Luke” entry in the Map of Jedi. Unboxing the missing Integer value cause the NullPointerException. Exceptional makes it easy to understand that the get() returned null.

Exceptional benefits

Simplify support

NullPointerExceptions can be notoriously hard to diagnose. Exceptional adds the necessary information to understand the cause of a NPE’s quickly.

Speedup development and training

You increase the pace of development when developer no longer have to stare at stracktrace to understand what caused a NullPointerException.

For all Java versions

JEP 358 added Helpful NullPointerExceptions to the Java runtime as of Java 14. Exceptional brings the same benefits to those of us who can not yet transition the Java14 (or higher).

How many NullPointerExceptions can you find?

Take a look at the lookup() method below. From line 54 to say 56 there are no less that 3 potential NPE’s hidden in this otherwise simple method.

The unit tests fail1(), fial2() and fail3() are there to illustrate each possible NPE. Answers illustrated below….

Here are the answers. On the left the answers without Exceptional. As you can see you, you still have some staring to do to try and understand what went wrong. Or you can save yourself some time and look at the result on the right. Here the benefit of Exceptional becomes clear. The stacktrace is exactly the same but now you know right away what caused the NPE!

The standard NullPointerException without using Exceptional. Although each failure case is different the stacktrace provides no useful information.
Exceptional enhanced the NullPointerException by providing a clear message describing the cause of the problem.

Full IntelliJ IDEA Integration

The Exceptional plugin, currently in BETA, integrates seemlessly in the IntelliJ.