Skip to content

Commit c255af3

Browse files
committed
feat: 添加自定义异常类 SimpleException
1 parent b28e647 commit c255af3

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package info.cadecode.simple.common.exception;
2+
3+
import info.cadecode.simple.constant.ReasonEnum;
4+
5+
/**
6+
* @author Cade Li
7+
* @date 2021/7/16
8+
* @description: 自定义异常类总类
9+
*/
10+
public class SimpleException extends RuntimeException {
11+
12+
13+
private final Integer code;
14+
private final String msg;
15+
16+
17+
public SimpleException(Integer code, String msg) {
18+
this.code = code;
19+
this.msg = msg;
20+
}
21+
22+
23+
public SimpleException(ReasonEnum reasonEnum) {
24+
this.code = reasonEnum.getCode();
25+
this.msg = reasonEnum.getMsg();
26+
}
27+
28+
public Integer getCode() {
29+
return code;
30+
}
31+
32+
public String getMsg() {
33+
return msg;
34+
}
35+
}

0 commit comments

Comments
 (0)