package com.zcloud.util;

/**
 * 说明：TODO
 * 作者：wangxuan
 * 官网：www.zcloudchina.com
 */

public class BizException extends RuntimeException implements BaseResultInterface {

    private static final long serialVersionUID = 1L;


    /**
     * 错误码
     */
    private String code;

    /**
     * 错误信息
     */
    private String message;

    public BizException() {
        super();
    }

    public BizException(CodeMessageEnum codeMessageEnum) {
        super(codeMessageEnum.getCode(),new Throwable());
        this.code = codeMessageEnum.getCode();
        this.message = codeMessageEnum.getMessage();
    }

    public BizException(CodeMessageEnum codeMessageEnum, Throwable cause) {
        super(codeMessageEnum.getCode(), cause);
        this.code = codeMessageEnum.getCode();
        this.message = codeMessageEnum.getMessage();
    }
    public BizException(CodeMessageEnum codeMessageEnum, Throwable cause, String details) {
        super(codeMessageEnum.getCode(), cause);
        this.code = codeMessageEnum.getCode();
        this.message = codeMessageEnum.getMessage() + details;
    }
    public BizException(CodeMessageEnum codeMessageEnum, String message, Throwable cause) {
        super(codeMessageEnum.getCode(), cause);
        this.code = codeMessageEnum.getCode();
        this.message = message;
    }

    public BizException(String message) {
        super(message);
        this.message = message;
    }

    public BizException(String code, String message) {
        super(code);
        this.code = code;
        this.message = message;
    }

    public BizException(String code, String message, Throwable cause) {
        super(code, cause);
        this.code = code;
        this.message = message;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }


    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }
}


