Class ExceptionUtils


public final class ExceptionUtils extends Object
The Exception Utils class provide utility method for exception handling.
Stepan Vavra (
  • Method Details

    • exceptionStackTraceAsString

      public static String exceptionStackTraceAsString(Throwable t)
      Gets the stack trace of the provided throwable as a string.
      t - the exception to get the stack trace for.
      the stack trace as a string.
    • conditionallyReThrow

      public static <T extends Exception> void conditionallyReThrow(T e, boolean rethrow, Logger logger, String m, Level level) throws T
      Based on the rethrow parameter, either rethrows the supplied exception or logs the provided message at the given level.
      Type Parameters:
      T - the type of the exception to be conditionally rethrown.
      e - the exception to rethrow if rethrow is true.
      rethrow - whether to rethrow an exception or just log the provided message.
      logger - the logger to print the message with.
      m - the message to log if rethrow is false.
      level - the level of the logged message.
      T - if rethrow is true.