Package dev.nm.misc

Class ExceptionUtils


  • public final class ExceptionUtils
    extends Object
    Exception-related utility functions.
    • Method Detail

      • throwIfNotNull

        public static void throwIfNotNull​(RuntimeException error)
        This is a wrapper method that throws a RuntimeException if it is not null. It is used to avoid the slow and expensive creation of an exception object on each checking. For a sample usage,
        throwIfNotNull(cond ? null : new RuntimeException("msg"));
        It is important that we use lazy evaluation of the if statement.
        Parameters:
        error - the error thrown if the condition is not satisfied