18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
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
39
40
41
42
43
44
45
46
47
package org.yzh.commons.model;
 
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
 
/**
 * @author yezhihao
 * https://gitee.com/yezhihao/jt808-server
 */
@ToString
@Data
@Accessors(chain = true)
@JsonIgnoreProperties(value = {"stackTrace", "suppressed", "localizedMessage"})
public class APIException extends RuntimeException {
 
    private final int code;
    private String msg;
    private String details;
 
    public APIException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
 
    public APIException(APICode code) {
        this.code = code.getCode();
        this.msg = code.getMessage();
    }
 
    public APIException(APICode code, String msg) {
        this.code = code.getCode();
        this.msg = msg;
    }
 
    public APIException(APICode code, String msg, String details) {
        this.code = code.getCode();
        this.msg = msg;
        this.details = details;
    }
 
    public APIException(Throwable e) {
        super(e);
        this.code = APICodes.InternalError.getCode();
    }
}