Class ExceptionUtils

java.lang.Object
com.kingsrook.qqq.backend.core.utils.ExceptionUtils

public class ExceptionUtils extends Object
Utility class for working with exceptions.
  • Constructor Details

    • ExceptionUtils

      public ExceptionUtils()
  • Method Details

    • findClassInRootChain

      public static <T extends Throwable> T findClassInRootChain(Throwable e, Class<T> targetClass)
      Find a specific exception class in an exception's caused-by chain. Returns null if not found. Be aware, uses class.isInstance (so sub-classes get found).
    • getClassListFromRootChain

      public static <T extends Throwable> List<T> getClassListFromRootChain(Throwable e, Class<T> targetClass)
      Find a list of exceptions of the given class in an exception's caused-by chain. Returns empty list if none found.
    • getRootException

      public static Throwable getRootException(Exception exception)
      Get the root exception in a caused-by-chain.
    • concatenateMessagesFromChain

      public static String concatenateMessagesFromChain(Exception exception)
    • getTopAndBottomMessages

      public static String getTopAndBottomMessages(Exception e)
      Get the messages from the top invalid input: '&' bottoms (root) of an exception. If there's no root, just return the top (e.g., parameter)'s message. If they are both found, put ": " between them.