package com.muchinfo.mtp3century.exception;

import com.muchinfo.mtp3common.enumtype.GlobalExceptionEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *  自定义全局异常类GlobalException
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class GlobalException extends RuntimeException{
    private Integer code;
    private String globalMessage;
    private String languages;

    public GlobalException() {
    }

    public GlobalException(String message) {
        super(message);
    }

    public GlobalException(Integer code, String message,String languages) {
        super(message);
        this.code = code;
        this.globalMessage = message;
        this.languages = languages;
    }

    /**
     * 建立直接传入枚举做参数可以直接创建对应的异常
     * @param globalExceptionEnum
     */
    public GlobalException(GlobalExceptionEnum globalExceptionEnum) {
        super(globalExceptionEnum.getMessage());
        this.code = globalExceptionEnum.getCode();
        this.globalMessage = globalExceptionEnum.getMessage();
    }
}
