Class ExceptionUtil


  • public class ExceptionUtil
    extends Object
    • Constructor Detail

      • ExceptionUtil

        public ExceptionUtil()
    • Method Detail

      • catchAll

        public static Runnable catchAll​(@NotNull
                                        String actionName,
                                        @NotNull
                                        Runnable action)
        Wraps given runnable with another runnable that catches Throwable. If given runnable failed, it will log this as Warn into logger created from given runnable class.
        Parameters:
        actionName - text to be included into LOG.warn message
        action - action to wrap
        Returns:
        wrapped action, run method will not throw an exception
        Since:
        5.1.3
      • rethrowAsRuntimeException

        @Contract("_ -> fail")
        public static void rethrowAsRuntimeException​(@NotNull
                                                     Throwable t)
                                              throws RuntimeException
        Accepts exception and wraps it into RuntimeException. Wrapping is not performed if exception is RuntimeException already.
        Parameters:
        t - exception to wrap
        Throws:
        RuntimeException - an exception
      • dumpStacktrace

        public static void dumpStacktrace​(@NotNull
                                          StringBuilder stringBuffer,
                                          @NotNull
                                          Throwable exception)
        // TBD Moved here from jetbrains.spring.web#TeamCityContextLoaderListener.
      • getCause

        @Nullable
        public static <T extends Throwable> T getCause​(@Nullable
                                                       Throwable e,
                                                       @NotNull
                                                       Class<T> clazz)
        Looks for specified class of error in cause chain.
      • getDisplayMessage

        @NotNull
        public static String getDisplayMessage​(@NotNull
                                               Throwable t)