- 论坛徽章:
- 0
|
package com.wm.affnet.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import com.wm.affnet.util.AppLogger;
public class BaseException extends Exception implements IExceptionHandler {
protected Throwable rootCause = null;
private List exceptions = new ArrayList();
private String exceptionType;
private String exceptionMsg;
public String getExceptionType() {
return exceptionType;
}
public void setExceptionType(String exceptionType) {
this.exceptionType = exceptionType;
}
public String getExceptionMsg() {
return exceptionMsg;
}
public void setExceptionMsg(String exceptionMsg) {
this.exceptionMsg = exceptionMsg;
}
public BaseException() {
super();
}
public BaseException(Throwable rootCause) {
this.rootCause = rootCause;
}
public void addException(Exception ex) {
exceptions.add(ex);
}
public Throwable getRootCause() {
return rootCause;
}
public void setRootCause(Throwable rootCause) {
this.rootCause = rootCause;
}
public List getExceptions() {
return exceptions;
}
public void setExceptions(List exceptions) {
this.exceptions = exceptions;
}
public void printStackTrace() {
printStackTrace(System.err);
}
@Override
public void printStackTrace(PrintStream outStream) {
printStackTrace(new PrintWriter(outStream));
}
@Override
public void printStackTrace(PrintWriter writer) {
super.printStackTrace(writer);
if (this.getRootCause() != null) {
this.getRootCause().printStackTrace(writer);
}
writer.flush();
}
public void handler() {
try {
AppLogger.error(getClass(), "\n" + this.getExceptionType() + ":" + this.getExceptionMsg(), this
.getRootCause());
} catch (Exception e1) {
AppLogger.info(getClass(), "\n" + "loging log failure");
}
}
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103458/showart_2032714.html |
|