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

📄 baseexception.java

📁 基本库存管理系统的框架 struts hibernate
💻 JAVA
字号:
package com.strong.ims.comutil.exception;

import com.strong.ims.comutil.IConstants; 

/**
 * 
 * @author 
 * 自定义 异常类
 */
public class BaseException extends Exception {

	/**
	 * 继承Throwable下的exception类
	 */
	
	/**
	 * 通过[类属性]
	 * 支持异常级联
	 * 不支持异常多样化
	 * 支持于Struts Resources Bundle绑定
	 * 不支持复合式消息 
	 * 
	 */
	 protected Throwable rootCause = null;      //原始异常--支持异常的级联
	 protected String messageKey = null;        //消息key--支持和Struts的Resource Bundle绑定
	 protected String messageStr = null;        //异常描述--不支持复合消息
	
	/**
	 * 空构造方法
	 *
	 */
	public BaseException( ) {
		super();
	}
	
	/**
	 * 构造方法
	 */
	public BaseException(Throwable rootCause) {
		this.rootCause = rootCause;                    //原始异常
		this.messageKey = IConstants.ERROR_DEFAULT;    //默认异常key
		//异常描述 null
	}
	
	/**
	 * 构造方法
	 * @param rootCause
	 * @param messageStr
	 */
	public BaseException(Throwable rootCause,String messageStr) {
		this.rootCause = rootCause;                    //原始异常
		this.messageKey = IConstants.ERROR_DEFAULT;    //默认异常 key
		this.messageStr = messageStr;				   //异常 描述信息
	}
	
	/**
	 * 
	 */
	//public BaseException(Throwable rootCause,String messageKey) {
	//	this.rootCause = rootCause;       //原始异常
	//	this.messageKey = messageKey;    //默认异常 key
	//				   //异常 描述信息 null
	//}
	
	public BaseException(String messageKey,String messageStr) {
		this.messageKey = messageKey;                  //消息key
		this.messageStr = messageStr;                  //异常描述
		//原始异常 null
	}
	/**
	 * @inheritDoc 构造方法
	 * @param rootCause
	 * @param messageStr
	 * @param messageKey
	 */
	public BaseException(Throwable rootCause,String messageStr,String messageKey) {
		this.rootCause = rootCause;                    //原始异常
		this.messageKey = messageKey;    			   //异常 消息key
		this.messageStr = messageStr;                  //异常 描述信息
	}
	
	/**
	 * 返回消息Key
	 * @return
	 */
	public String getMessageKey() {
		return messageKey;
	}

	/**
	 * 设定消息key
	 * @param messageKey
	 */
	public void setMessageKey(String messageKey) {
		this.messageKey = messageKey;
	}

	/**
	 * 返回错误描述
	 * @return
	 */
	public String getMessageStr() {
		return messageStr;
	}

	/**
	 * 设定错误描述
	 * @param messageStr
	 */
	public void setMessageStr(String messageStr) {
		this.messageStr = messageStr;
	}

	/**
	 * 返回原始异常
	 * @return
	 */
	public Throwable getRootCause() {
		return rootCause;
	}
	
	/**
	 * 设定原始异常
	 * @param rootCause
	 */
	public void setRootCause(Throwable rootCause) {
		this.rootCause = rootCause;
	}

}

⌨️ 快捷键说明

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