BusinessException.java
1.39 KB
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 cn.com.glsx.dj.weapp.exception;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
/**
* 业务异常
* <P>Description: </P>
*
* @author Alvin
* @version 1.0
*/
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
private ResultEntity<Object> resultEntity;
public BusinessException(String message) {
super(message);
this.resultEntity = new ResultEntity<Object>();
this.resultEntity.setReturnCode(ResultEntity.ERROR);
this.resultEntity.setErrId(DefaultErrorEnum.SERVER_ERROR.getValue());
this.resultEntity.setMessage(message);
}
public BusinessException(String errorCode, String message) {
super(message);
this.resultEntity = new ResultEntity<Object>();
this.resultEntity.setReturnCode(ResultEntity.ERROR);
this.resultEntity.setErrId(errorCode);
this.resultEntity.setMessage(message);
}
public BusinessException(ResultEntity<Object> resultEntity) {
super(resultEntity.getMessage());
this.resultEntity = resultEntity;
this.resultEntity.setReturnCode(ResultEntity.ERROR);
this.resultEntity.setErrId(DefaultErrorEnum.SERVER_ERROR.getValue());
}
public ResultEntity<Object> getResultEntity() {
return resultEntity;
}
}