baseappexception.java

来自「基于struts的一个异常处理框架,采用aop原理来统一处理异常。」· Java 代码 · 共 83 行

JAVA
83
字号
package org.expframework.exceptions;

/**
 * A base class for all checked exceptions in the application.
 * 
 * @author ShriKant
 * 
 * @version 1.0
 */
public class BaseAppException extends Exception {

    static final long serialVersionUID = -5829545098534135052L;

    /**
     * the message of the BaseAppException.
     */
    private String exceptionMessage;

    /**
     * A public constructor for BaseAppException containing no arguments.
     *  
     */
    public BaseAppException() {
    }

    /**
     * A public constructor for BaseAppException specifying exception message.
     * <p>
     * 
     * @param msg
     *            exception message.
     *  
     */
    public BaseAppException(String msg) {
        this.exceptionMessage = msg;
    }

    /**
     * A public constructor of <code>BaseAppException</code> containing
     * message and root cause (as <code>Throwable</code>) of the exception.
     * 
     * @param msg
     *            exception message.
     * @param e
     *            Throwable object.
     *  
     */
    public BaseAppException(String msg, Throwable e) {
        this.exceptionMessage = msg;
        this.initCause(e);
    }

    /**
     * sets the root cause of the exception. Used for setting Java built in
     * exception in <code>BaseAppException</code>.
     * 
     * @param e
     *            Throwable object.
     *  
     */
    public void setCause(Throwable e) {
        this.initCause(e);
    }

    /*
     * Gets the class name and exception message.
     * 
     * @see java.lang.Object#toString()
     */
    public String toString() {
        String s = getClass().getName();
        return s + ": " + exceptionMessage;
    }

    /*
     * Gets the message of the exception. equivalent to Exception.getMessage().
     * 
     * @see java.lang.Throwable#getMessage()
     */
    public String getMessage() {
        return exceptionMessage;
    }
}

⌨️ 快捷键说明

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