baseexception.java

来自「spring struts hibernate 集成开发的web应用」· Java 代码 · 共 58 行

JAVA
58
字号
/**
 * 
 */
package com.sc.util;
import java.util.*;
import java.io.*;

/**
 * This is the common superclass for all application .this class
 * and its subclass support the chained exception facility that 
 * allows a root cause Throwable to be wrapped by this class or one
 * of its descendants. This class also supports multiple exceptions via
 * the exceptionList field.
 * 
 * <p>title:多样化异常</p>
 * @author cnsdl
 * @since 1.4
 * @version 1.0
 *
 */
public class BaseException extends Exception{
	protected Throwable rootCause = null;
	private List exceptions = new ArrayList();
	
	public BaseException(){
		super();
	}
	public BaseException(Throwable rootCause){
		this.rootCause = rootCause;
	}
	public List getExceptions(){
		return exceptions;
	}
	public void addException(BaseException ex){
		exceptions.add( ex );
	}
	public void setRootCause(Throwable anException){
		rootCause = anException;
	}
	public Throwable getRootCause(){
		return rootCause;
	}
	public void printStackTrace(){
		printStackTrace(System.err);
	}
	public void printStackTrace(PrintStream outStream){
		printStackTrace(new PrintWriter(outStream));
	}
	public void printStackTrace(PrintWriter writer){
		super.printStackTrace(writer);
		
		if (getRootCause() != null){
			getRootCause().printStackTrace(writer);
		}
		writer.flush();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?