BusinessException.java
930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.youjia.common.exception;
import com.youjia.common.core.ResultCode;
import lombok.Getter;
import java.io.Serial;
/**
* 业务异常。由全局异常处理器统一转换为 {@link com.youjia.common.core.Result}。
*/
@Getter
public class BusinessException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
private final Integer code;
public BusinessException(String message) {
super(message);
this.code = ResultCode.FAIL.getCode();
}
public BusinessException(ResultCode resultCode) {
super(resultCode.getMessage());
this.code = resultCode.getCode();
}
public BusinessException(ResultCode resultCode, String message) {
super(message);
this.code = resultCode.getCode();
}
public BusinessException(Integer code, String message) {
super(message);
this.code = code;
}
}