异常信息实体类

异常信息实体类

@Data
public class GlobalException extends RuntimeException {

    private static final long serialVersionUID = 5983014993412756767L;
    /**
     * 错误编码
     */
    private String code;
    /**
     * 错误提示
     */
    private String msg;
    /**
     * 错误信息
     */
    private Exception exception;

    /**
     * 异常信息
     *
     * @param msg
     * @param e
     */
    public GlobalException(final String code, final String msg, final Exception e) {
        super(String.valueOf(code).concat(msg));
        this.code = code;
        this.msg = msg;
        this.exception = e;
    }

    /**
     * 异常信息
     *
     * @param msg
     * @param code
     */
    public GlobalException(final String code, final String msg) {
        super(String.valueOf(code).concat(msg));
        this.code = code;
        this.msg = msg;
    }

    /**
     * 异常信息
     *
     * @param resultEnum
     * @param e
     */
    public GlobalException(ResultEnum resultEnum, final Exception e) {
        super(String.valueOf(resultEnum.getCode()).concat(resultEnum.getMsg()));
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
        this.exception = e;
    }

    /**
     * 异常信息
     *
     * @param resultEnum
     */
    public GlobalException(ResultEnum resultEnum) {
        super(String.valueOf(resultEnum.getCode()).concat(resultEnum.getMsg()));
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
        this.exception = null;
    }

}
使用
 throw new GlobalException(ResultEnum.ERROR_2016);	
 return ResultUtil.Error(new GlobalException(ResultEnum.ERROR_2013));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值