⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseexception.java

📁 这是本人以前在学校时
💻 JAVA
字号:
package com.funddeal.app_exception;

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * 这是所有应用异常的共同超类。这个类及其子类支持链接式异常,
 * 可以让根源的Throwable类被这个类或其子类包装起来。
 * 这个类还会利用exceptionList字段支持多个异常。
 */
public class BaseException extends Exception {

	private static final long serialVersionUID = 1L;
	protected Throwable rootCause=null;
	private List<Exception> exceptions = new ArrayList<Exception>();
	private String messageKey=null;
	private Object[] messageArgs=null;
	
	public BaseException() {
		super();
	}
	
	public BaseException(Throwable rootCause) {
		this.rootCause=rootCause;
	}

	public BaseException(String message) {
		super(message);
	}

	public BaseException(String message, Throwable rootCause) {
		super(message, rootCause);
		this.rootCause=rootCause;
	}

	public List getException()
	{
		return this.exceptions;
	}
	
	public void addException(BaseException ex)
	{
		this.exceptions.add(ex);
	}
	
	public void setMessageKey(String key)
	{
		this.messageKey=key;
	}
	
	public String getMessageKey()
	{
		return this.messageKey;
	}
	
	public void setMessageArgs(Object[] args)
	{
		this.messageArgs=args;
	}
	
	public Object[] getMessageArgs()
	{
		return this.messageArgs;
	}
	
	public void setRootCause(Throwable anException)
	{
		this.rootCause=anException;
	}
	
	public Throwable getRootCause()
	{
		return this.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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -