package com.salpa.subject.domain.error;

import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public class MetaopsException extends RuntimeException {

    @Getter
    private MetaopsErrors errorCodeMessage;

    @Getter
    private String errCode;

    @Getter
    private String errMessage;

    /**
     * @param errorCodeMessage 错误信息
     */
    public MetaopsException(MetaopsErrors errorCodeMessage) {
        super(errorCodeMessage.getErrMessage());
        this.errorCodeMessage = errorCodeMessage;
        this.errCode = errorCodeMessage.getErrCode();
        this.errMessage = errorCodeMessage.getErrMessage();
    }

    /**
     * @param errorCodeMessage 错误信息
     * @param overrideMessage  覆盖 message
     */
    public MetaopsException(MetaopsErrors errorCodeMessage, String overrideMessage) {
        super(overrideMessage);
        this.errorCodeMessage = errorCodeMessage;
        this.errCode = errorCodeMessage.getErrCode();
        this.errMessage = overrideMessage;
    }

    /**
     * @param errorCodeMessage 错误信息
     * @param cause            root cause
     */
    public MetaopsException(MetaopsErrors errorCodeMessage, Throwable cause) {
        super(errorCodeMessage.getErrMessage(), cause);
        this.errorCodeMessage = errorCodeMessage;
        this.errCode = errorCodeMessage.getErrCode();
        this.errMessage = errorCodeMessage.getErrMessage();
    }

    public MetaopsException(MetaopsErrors errorCodeMessage, String overrideMessage, Throwable cause) {
        super(overrideMessage, cause);
        this.errorCodeMessage = errorCodeMessage;
        this.errCode = errorCodeMessage.getErrCode();
        this.errMessage = overrideMessage;
    }
}
