Class ThrowableTools


  • public class ThrowableTools
    extends Object
    This class provides tool methods for handling Throwable.
    • Constructor Detail

      • ThrowableTools

        public ThrowableTools()
    • Method Detail

      • merge

        public static Throwable merge​(Collection<Throwable> throwables)
        Merges the designated throwables by selecting the first most critical throwable (Error, Exception or RuntimeException), adds all other throwables as suppressed to the selected throwable and returns the selected one.
        Parameters:
        throwables - The throwables which to merge to one throwable which will be the most critical one from the list.
        Returns:
        The first occurring most critical throwable from the designated throwables with all other throwables as suppressed ones.
      • merge

        public static <T extends Throwable> T merge​(T selected,
                                                    Collection<Throwable> throwables)
        Adds the designated throwables as suppressed ones to the designated selected throwable. If the selected one is in the collection, it will not be considered again.
        Parameters:
        selected - The selected throwable to which to add the designated other throwables.
        throwables - The throwables which to add as suppressed ones to the designated selected exception. If the selected one is in the collection, it will not be considered again.
        Returns:
        The designated selected throwable having the other designated throwables as suppressed ones.