统一异常类

package com.imooc.mall.exception;

/**
 * 描述:     统一异常
 */
public class ImoocMallException extends RuntimeException {

    private final Integer code;
    private final String message;

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

    public ImoocMallException(ImoocMallExceptionEnum exceptionEnum) {
        this(exceptionEnum.getCode(), exceptionEnum.getMsg());
    }

    public Integer getCode() {
        return code;
    }

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

posted @ 2021-05-19 16:36  little_mao  阅读(68)  评论(0编辑  收藏  举报