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;
|
}
|
}
|