青羊经侦大队-数据平台
baizonghao
2023-05-10 325b4c5c4d23d6ec565d85b94f95cabde32812e8
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
package com.example.jz.exception;
 
import com.example.jz.enums.BusinessHttpStatus;
import org.springframework.http.HttpStatus;
 
public class BusinessException extends RuntimeException {
 
    private static final long serialVersionUID = -4137688758944857209L;
 
    /**
     * http状态码
     */
    private Integer httpStatusCode;
 
    /**
     * @param httpStatus http状态码
     */
    public BusinessException(BusinessHttpStatus httpStatus) {
        super(httpStatus.getMsg());
        this.httpStatusCode = httpStatus.value();
    }
 
    /**
     * @param httpStatus http状态码
     */
    public BusinessException(BusinessHttpStatus httpStatus, String msg) {
        super(msg);
        this.httpStatusCode = httpStatus.value();
    }
 
    public BusinessException(String msg) {
        super(msg);
        this.httpStatusCode = BusinessHttpStatus.BAD_EXCEPTION.value();
    }
 
    public Integer getHttpStatusCode() {
        return httpStatusCode;
    }
}