package com.cf.imes.framework.common.exception;

import com.cf.imes.framework.common.exception.enums.ServiceErrorCodeRange;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 支付系统异常 Exception
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PayException extends RuntimeException {

    /**
     * 业务错误码
     *
     * @see ServiceErrorCodeRange
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String message;

    public PayException(Throwable cause) {
        super(cause);
    }

    /**
     * 空构造方法，避免反序列化问题
     */
    public PayException() {
    }

    public PayException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }

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

    public Integer getCode() {
        return code;
    }

    public PayException setCode(Integer code) {
        this.code = code;
        return this;
    }

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

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