You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
802 B
43 lines
802 B
package net.educoder.exception;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
/**
|
|
* @Author: youys
|
|
* @Date: 2022/8/16
|
|
* @Description:
|
|
*/
|
|
public class BusinessException extends RuntimeException{
|
|
|
|
private int code;
|
|
private String msg;
|
|
|
|
public int getCode() {
|
|
return code;
|
|
}
|
|
|
|
public String getMsg() {
|
|
return msg;
|
|
}
|
|
|
|
public BusinessException(int code, String msg) {
|
|
super(msg);
|
|
this.code = code;
|
|
this.msg = msg;
|
|
}
|
|
|
|
public BusinessException(String msg) {
|
|
super(msg);
|
|
this.code = -1;
|
|
this.msg = msg;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
JSONObject str = new JSONObject();
|
|
str.put("code", getCode());
|
|
str.put("msg", getMsg());
|
|
return str.toJSONString();
|
|
}
|
|
}
|