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.
31 lines
658 B
31 lines
658 B
package com.example.demo.Util;
|
|
|
|
/**
|
|
* @program: GOLD
|
|
* @ClassName BusinessException
|
|
* @description:
|
|
* @author: huangqizhen
|
|
* @create: 2025−06-23 14:58
|
|
* @Version 1.0
|
|
**/
|
|
|
|
import lombok.Getter;
|
|
|
|
/**
|
|
* 业务异常,可抛出到前端
|
|
*/
|
|
@Getter
|
|
public class BusinessException extends RuntimeException {
|
|
private int code; // 业务状态码
|
|
// 使用默认状态码0的构造方法
|
|
public BusinessException(String message) {
|
|
this(400, message); // 默认状态码400
|
|
}
|
|
|
|
// 指定状态码的构造方法
|
|
public BusinessException(int code, String message) {
|
|
super(message);
|
|
this.code = code;
|
|
}
|
|
|
|
}
|