liujie
2026-03-11 f022fcea3c3fffc49bccbe99ec9f8bd8f703c9a6
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package com.xiaopeng.common.core.exception;
 
/**
 * 业务异常
 * 
 * @author xiaopeng
 */
public final class ServiceException extends RuntimeException
{
    private static final long serialVersionUID = 1L;
 
    /**
     * 错误码
     */
    private Integer code;
 
    /**
     * 错误提示
     */
    private String message;
 
    /**
     * 错误明细,内部调试错误
     *
     * 和 {@link CommonResult#getDetailMessage()} 一致的设计
     */
    private String detailMessage;
 
    /**
     * 国际化消息键,委托给 MessageUtils 获取国际化翻译值
     */
    private String messageKey;
    /**
     * 国际化消息参数,委托给 MessageUtils 获取国际化翻译值
     */
    private Object[] args;
 
    public Object[] getArgs() {
        return args;
    }
 
    public void setArgs(Object[] args) {
        this.args = args;
    }
 
    public void setCode(Integer code) {
        this.code = code;
    }
 
    public String getMessageKey() {
        return messageKey;
    }
 
    public void setMessageKey(String messageKey) {
        this.messageKey = messageKey;
    }
 
    /**
     * 空构造方法,避免反序列化问题
     */
    public ServiceException()
    {
    }
 
    public ServiceException(String message)
    {
        this.message = message;
    }
 
    public ServiceException(String message, Integer code,String messageKey)
    {
        this.message = message;
        this.code = code;
        this.messageKey = messageKey;
    }
 
    public ServiceException(String message, String messageKey, Object[] args)
    {
        this.message = message;
        this.messageKey = messageKey;
        this.args = args;
    }
 
    public ServiceException(String message, String messageKey) {
        this.message = message;
        this.messageKey = messageKey;
    }
 
    public String getDetailMessage()
    {
        return detailMessage;
    }
 
    @Override
    public String getMessage()
    {
        return message;
    }
 
    public Integer getCode()
    {
        return code;
    }
 
    public ServiceException setMessage(String message)
    {
        this.message = message;
        return this;
    }
 
    public ServiceException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }
 
}