package com.ssm.manage.entity;


import com.ssm.manage.response.ResponseCode;

public class SmsException extends Exception {

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

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

    public SmsException(){}

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

    public SmsException(ResponseCode responseCode){
        this.code = responseCode.getCode();
        this.message = responseCode.getMsg();
    }

    public SmsException(ResponseCode responseCode, String message){
        this.code = responseCode.getCode();
        this.message = String.format(responseCode.getMsg(),message);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

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

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SmsException that = (SmsException) o;

        return !(code != null ? !code.equals(that.code) : that.code != null);

    }

    @Override
    public int hashCode() {
        return code != null ? code.hashCode() : 0;
    }
}
