HttpCodeException.java 1.36 KB
package com.yanzuoguang.util.exception;

/**
 * 途比达异常信息
 *
 * @author 颜佐光
 */
public class HttpCodeException extends RuntimeException {


    private static final long serialVersionUID = -4625832188480820883L;
    /**
     * 错误码
     */
    private String code = "99";

    /**
     * 包含的数据
     */
    private Object target = null;

    /**
     * 获取错误码
     *
     * @return 返回的结果
     */
    public String getCode() {
        return this.code;
    }

    /**
     * 来源数据
     *
     * @return
     */
    public Object getTarget() {
        return target;
    }

    /**
     * 构造函数
     * throw new CodeException("01","该订单已过期",order);
     * throw new CodeException("02","该订单未到使用时间",order);
     *
     * @param code     错误码
     * @param message  错误消息
     * @param target   错误数据源,如订单数据
     * @param cause   the cause (which is saved for later retrieval by the
     *                {@link #getCause()} method).  (A <tt>null</tt> value is
     *                permitted, and indicates that the cause is nonexistent or
     *                unknown.)
     */
    public HttpCodeException(String code, String message, Object target, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.target = target;
    }
}