无关风月
2024-07-11 eb6b6dbb35a9f029e0b7d269773685c19fd40976
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.dsh.guns.core.exception;
 
 
 
/**
 * 业务异常
 *
 * @author liheng
 */
public class ServiceException extends RuntimeException {
 
    private static final long serialVersionUID = -232388151980021793L;
 
    /**
     * 自定义异常码
     */
    private int code = GunsExceptionEnum.SERVER_ERROR.getCode();
 
    private Object data;
 
    public ServiceException() {
        super();
    }
 
    /**
     * 将定义的异常信息赋给异常
     *
     * @param code
     * @param msg
     */
    public ServiceException(int code, String msg) {
        this(code, msg, null);
    }
 
    public ServiceException(GunsExceptionEnum code) {
        this(code, null);
    }
 
    public ServiceException(GunsExceptionEnum code, Object o) {
        super(code.getMessage());
        this.code = code.getCode();
        this.data = o;
    }
 
    public ServiceException(int code, String msg, Object o) {
        super(msg);
        this.code = code;
        this.data = o;
    }
 
    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }
 
    public ServiceException(String message) {
        super(message);
    }
 
    public ServiceException(Throwable cause) {
        super(cause);
    }
 
    public int getCode() {
        return code;
    }
 
    public void setCode(int code) {
        this.code = code;
    }
 
    public Object getData() {
        return data;
    }
 
    public void setData(Object data) {
        this.data = data;
    }
}