Chinaunix首页 | 论坛 | 博客
  • 博客访问: 13893
  • 博文数量: 12
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-19 15:05
文章分类

全部博文(12)

文章存档

2011年(1)

2009年(11)

我的朋友
最近访客

分类: Java

2009-08-20 12:03:07

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");
  }
 }
}
阅读(354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~