自定义异常类一般是为了配合自定义日志用的,对程序员关注的异常信息能更有针对性,自定义异常一般都会继承
RuntimeException类.并实现其中的方法,同时将自定义异常信息向上传递给父类直至*父类Throwable
package app.base;
import org.apache.log4j.Logger;
/**
*
*
* @author hxf
*/
public class ServiceException extends RuntimeException {
private static final long serialVersionUID = 3583566093089790852L;
private static Logger log = Logger.getLogger(ServiceException.class);
public ServiceException() {
super();
}
public ServiceException(String message) {
super(message);
if (log.isDebugEnabled()) {
log.debug(message);
}
}
public ServiceException(Exception cause) {
super(cause);
if (log.isDebugEnabled()) {
log.debug(cause.getMessage());
}
}
public ServiceException(String message, Throwable cause) {
super(message, cause);
if (log.isDebugEnabled()) {
log.debug(message);
}
}
}
ThrowAble会调用本地方法