懒羊羊
2024-01-31 e57a8990ae56f657a59c435a0613c5f7a8728003
提交 | 用户 | 时间
e57a89 1 package com.jcdm.common.exception;
2
3 /**
4  * 业务异常
5  * 
6  * @author jc
7  */
8 public final class ServiceException extends RuntimeException
9 {
10     private static final long serialVersionUID = 1L;
11
12     /**
13      * 错误码
14      */
15     private Integer code;
16
17     /**
18      * 错误提示
19      */
20     private String message;
21
22     /**
23      * 错误明细,内部调试错误
24      *
25      * 和 {@link CommonResult#getDetailMessage()} 一致的设计
26      */
27     private String detailMessage;
28
29     /**
30      * 空构造方法,避免反序列化问题
31      */
32     public ServiceException()
33     {
34     }
35
36     public ServiceException(String message)
37     {
38         this.message = message;
39     }
40
41     public ServiceException(String message, Integer code)
42     {
43         this.message = message;
44         this.code = code;
45     }
46
47     public String getDetailMessage()
48     {
49         return detailMessage;
50     }
51
52     @Override
53     public String getMessage()
54     {
55         return message;
56     }
57
58     public Integer getCode()
59     {
60         return code;
61     }
62
63     public ServiceException setMessage(String message)
64     {
65         this.message = message;
66         return this;
67     }
68
69     public ServiceException setDetailMessage(String detailMessage)
70     {
71         this.detailMessage = detailMessage;
72         return this;
73     }
74 }