| 构造器和说明 |
|---|
ExceptionKit() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
causedBy(Throwable throwable,
Class<? extends Throwable> causeType)
检查异常是否由指定类型的异常引起。
|
static List<Throwable> |
getCauses(Throwable throwable)
取得包括当前异常在内的所有的causes异常,按出现的顺序排列。
|
static List<Throwable> |
getCauses(Throwable throwable,
boolean reversed)
取得包括当前异常在内的所有的causes异常,按出现的顺序排列
|
static Throwable |
getRootCause(Throwable throwable)
取得最根本的异常。
|
static String |
getStackTrace(Throwable throwable)
取得异常的stacktrace字符串。
|
static void |
makeRunTime() |
static void |
makeRunTime(String message,
Object... args) |
static void |
makeRuntime(String message,
Throwable cause,
Object... args) |
static void |
makeRuntime(Throwable cause) |
static void |
makeRunTimeWhen(boolean flag,
String message,
Object... args) |
static void |
throwExceptionOrError(Throwable throwable)
抛出Throwable,但不需要声明throws Throwable,区分Exception 或Error。
|
static void |
throwRuntimeExceptionOrError(Throwable throwable)
抛出Throwable,但不需要声明throws Throwable,区分 RuntimeException、Exception
或Error。
|
static RuntimeException |
toRuntimeException(Exception exception)
将异常转换成RuntimeException。
|
static RuntimeException |
toRuntimeException(Exception exception,
Class<? extends RuntimeException> runtimeExceptionClass)
将异常转换成RuntimeException。
|
public static void makeRunTime()
public static void makeRuntime(Throwable cause)
public static boolean causedBy(Throwable throwable, Class<? extends Throwable> causeType)
throwable - 受检异常causeType - 指定类型public static Throwable getRootCause(Throwable throwable)
throwable - 受检异常public static List<Throwable> getCauses(Throwable throwable)
throwable - 受检异常public static List<Throwable> getCauses(Throwable throwable, boolean reversed)
throwable - 受检异常reversed - 是否反向public static RuntimeException toRuntimeException(Exception exception)
exception - 受检异常public static RuntimeException toRuntimeException(Exception exception, Class<? extends RuntimeException> runtimeExceptionClass)
exception - 受检异常runtimeExceptionClass - 转换异常的类型public static void throwExceptionOrError(Throwable throwable) throws Exception
throwable - 受检异常Exceptionpublic static void throwRuntimeExceptionOrError(Throwable throwable)
throwable - 受检异常Copyright © 2016. All rights reserved.