Package dev.nm.misc
Class ExceptionUtils
- java.lang.Object
-
- dev.nm.misc.ExceptionUtils
-
public final class ExceptionUtils extends Object
Exception-related utility functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
throwIfNotNull(RuntimeException error)
This is a wrapper method that throws aRuntimeException
if it is notnull
.
-
-
-
Method Detail
-
throwIfNotNull
public static void throwIfNotNull(RuntimeException error)
This is a wrapper method that throws aRuntimeException
if it is notnull
. It is used to avoid the slow and expensive creation of an exception object on each checking. For a sample usage,
It is important that we use lazy evaluation of thethrowIfNotNull(cond ? null : new RuntimeException("msg"));
if
statement.- Parameters:
error
- the error thrown if the condition is not satisfied
-
-