businessexception.java

来自「this is very useful book for the learn o」· Java 代码 · 共 80 行

JAVA
80
字号
package edu.buptsse.sxjd.service;

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

/**
 *本类来源于孙卫琴的书,如不明白请请参照该书的讲解来理解
 * @author sun wei qin
 * 2007-1-10
 */
public class BusinessException extends Exception {

	protected Throwable rootCause = null;

	private List exceptions = new ArrayList();

	private String messageKey = null;

	private Object[] messageArgs = null;

	public BusinessException() {
		super();
	}

	public BusinessException(Throwable rootCause) {
		this.rootCause = rootCause;
	}

	public List getExceptions() {
		return exceptions;
	}

	@SuppressWarnings("unchecked")
	public void addException(BusinessException ex) {
		exceptions.add(ex);
	}

	public void setMessageKey(String key) {
		this.messageKey = key;
	}

	public String getMessageKey() {
		return messageKey;
	}

	public void setMessageArgs(Object[] args) {
		this.messageArgs = args;
	}

	public Object[] getMessageArgs() {
		return messageArgs;
	}

	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 + -
显示快捷键?