首页 > 其他分享 >自定义异常类

自定义异常类

时间:2023-10-05 22:00:39浏览次数:40  
标签:code String 自定义 super EmosException msg 异常 public

继承runtimeexception可以不处理异常:

package com.example.emos.wx.exception;
import lombok.Data;
@Data
public class EmosException extends RuntimeException{
    private String msg;
    private int code = 500;

    public EmosException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public EmosException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public EmosException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public EmosException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }
}

  

标签:code,String,自定义,super,EmosException,msg,异常,public
From: https://www.cnblogs.com/sgj191024/p/17743990.html

相关文章