📄 exceptionutils.java
字号:
package com.cownew.ctk.common;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;
import org.apache.log4j.Logger;
public class ExceptionUtils
{
/**
* convert Throwable to CTKRunTimeException
*
* @param e
* @return
*/
public static CTKRunTimeException toRuntimeException(Throwable e)
{
CTKRunTimeException re = new CTKRunTimeException(e);
re.setStackTrace(e.getStackTrace());
Logger.getLogger(ExceptionUtils.class).error(e.getMessage(),e);
return re;
}
/**
* 得到真正的异常(脱掉InvocationTargetException UndeclaredThrowableException
*CTKRunTimeException等)
* @param t
* @return
*/
public static Throwable getRealThrowable(Throwable t)
{
Throwable realT = t;
if (t instanceof InvocationTargetException)
{
Throwable targetException = ((InvocationTargetException) t)
.getTargetException();
realT = getRealThrowable(targetException);
} else if (t instanceof UndeclaredThrowableException)
{
UndeclaredThrowableException unException = (UndeclaredThrowableException) t;
realT = getRealThrowable(unException.getUndeclaredThrowable());
}else if (t instanceof CTKRunTimeException)
{
CTKRunTimeException re = (CTKRunTimeException) t;
realT = getRealThrowable(re.getCause());
}
return realT;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -