Package jetbrains.buildServer.util
Class ExceptionUtil
- java.lang.Object
-
- jetbrains.buildServer.util.ExceptionUtil
-
public class ExceptionUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description ExceptionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Runnable
catchAll(String actionName, Runnable action)
Wraps given runnable with another runnable that catches Throwable.static void
dumpStacktrace(StringBuilder stringBuffer, Throwable exception)
// TBD Moved here from jetbrains.spring.web#TeamCityContextLoaderListener.static <T extends Throwable>
TgetCause(Throwable e, Class<T> clazz)
Looks for specified class of error in cause chain.static String
getDisplayMessage(Throwable t)
static void
log(Logger log, String prefixMessage, Throwable e)
Deprecated.since 9.0, useLogger.warnAndDebugDetails(String, Throwable)
static void
log(org.apache.log4j.Logger log, String prefixMessage, Throwable e)
Deprecated.since 9.0, useLogger.warnAndDebugDetails(String, Throwable)
static void
rethrowAsRuntimeException(Throwable t)
Accepts exception and wraps it into RuntimeException.
-
-
-
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 messageaction
- 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.
-
log
@Deprecated public static void log(@NotNull org.apache.log4j.Logger log, @NotNull String prefixMessage, @NotNull Throwable e)
Deprecated.since 9.0, useLogger.warnAndDebugDetails(String, Throwable)
-
log
@Deprecated public static void log(@NotNull Logger log, @NotNull String prefixMessage, @NotNull Throwable e)
Deprecated.since 9.0, useLogger.warnAndDebugDetails(String, Throwable)
-
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.
-
-