Class ThrowableUtils

java.lang.Object
VASSAL.tools.ThrowableUtils

public class ThrowableUtils extends Object
Since:
3.1.0
Author:
Joel Uckelman
  • Method Details

    • getAncestor

      public static <T extends Throwable> T getAncestor(Class<T> cl, Throwable t)
      Returns the most recent Throwable of class T in the proper causal history of the given Throwable, if one exists.
      Parameters:
      cl - the Class to search for
      t - the Throwable to check
      Returns:
      the proper ancestor of class T, or null if none exists
    • getRecent

      public static <T extends Throwable> T getRecent(Class<T> cl, Throwable t)
      Returns the most recent Throwable of class T in the (not necessarily proper) causal history of the given Throwable, if one exists. If the given Throwable is of class T, it will be returned.
      Parameters:
      cl - the Class to search for
      t - the Throwable to check
      Returns:
      the ancestor of class T, or null if none exists
    • throwAncestor

      public static <T extends Throwable> void throwAncestor(Class<T> cl, Throwable t) throws T
      Throws the most recent Throwable of class T in the proper causal history of the given Throwable, if one exists.
      Parameters:
      cl - the Class to search for
      t - the Throwable to check
      Throws:
      T - if an ancestor of that class is found
    • throwRecent

      public static <T extends Throwable> void throwRecent(Class<T> cl, Throwable t) throws T
      Throws the most recent Throwable of class T in the (not necessarily proper) causal history of the given Throwable, if one exists.
      Parameters:
      cl - the Class to search for
      t - the Throwable to check
      Throws:
      T - if an ancestor of that class is found
    • getStackTrace

      public static String getStackTrace(Throwable thrown)
      Converts a Throwable's stack trace to a String.
      Parameters:
      thrown - the Throwable with the stack trace to convert
      Returns:
      the stack trace as a String