Class ExceptionUtil


  • public class ExceptionUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ExceptionUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.Runnable catchAll​(java.lang.String actionName, java.lang.Runnable action)
      Wraps given runnable with another runnable that catches Throwable.
      static void dumpStacktrace​(java.lang.StringBuilder stringBuffer, java.lang.Throwable exception)
      // TBD Moved here from jetbrains.spring.web#TeamCityContextLoaderListener.
      static <T extends java.lang.Throwable>
      T
      getCause​(java.lang.Throwable e, java.lang.Class<T> clazz)
      Looks for specified class of error in cause chain.
      static java.lang.String getDisplayMessage​(java.lang.Throwable t)  
      static void log​(com.intellij.openapi.diagnostic.Logger log, java.lang.String prefixMessage, java.lang.Throwable e)
      Deprecated.
      since 9.0, use Logger#warnAndDebugDetails(String, Throwable)
      static void log​(org.apache.log4j.Logger log, java.lang.String prefixMessage, java.lang.Throwable e)
      Deprecated.
      since 9.0, use Logger#warnAndDebugDetails(String, Throwable)
      static void rethrowAsRuntimeException​(java.lang.Throwable t)
      Accepts exception and wraps it into RuntimeException.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExceptionUtil

        public ExceptionUtil()
    • Method Detail

      • catchAll

        public static java.lang.Runnable catchAll​(@NotNull
                                                  java.lang.String actionName,
                                                  @NotNull
                                                  java.lang.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
                                                     java.lang.Throwable t)
                                              throws java.lang.RuntimeException
        Accepts exception and wraps it into RuntimeException. Wrapping is not performed if exception is RuntimeException already.
        Parameters:
        t - exception to wrap
        Throws:
        java.lang.RuntimeException - an exception
      • dumpStacktrace

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

        @Deprecated
        public static void log​(@NotNull
                               org.apache.log4j.Logger log,
                               @NotNull
                               java.lang.String prefixMessage,
                               @NotNull
                               java.lang.Throwable e)
        Deprecated.
        since 9.0, use Logger#warnAndDebugDetails(String, Throwable)
      • log

        @Deprecated
        public static void log​(@NotNull
                               com.intellij.openapi.diagnostic.Logger log,
                               @NotNull
                               java.lang.String prefixMessage,
                               @NotNull
                               java.lang.Throwable e)
        Deprecated.
        since 9.0, use Logger#warnAndDebugDetails(String, Throwable)
      • getCause

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

        @NotNull
        public static java.lang.String getDisplayMessage​(@NotNull
                                                         java.lang.Throwable t)