common : 1.未登录异常使用错误码 401

release_1.0.0
xueqingkun 1 year ago
parent 2547c80a9a
commit c39f3d2a34

@ -8,7 +8,6 @@ import com.supervision.exception.BusinessException;
import com.supervision.exception.HumanException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
@ -72,7 +71,9 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
@ExceptionHandler(BusinessException.class)
public GlobalResult<?> businessExceptionResponse(BusinessException exception) {
log.error(exception.getMessage(), exception);
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getMessage(), "业务异常");
Integer code = null == exception.getCode() ? HttpStatus.INTERNAL_SERVER_ERROR.value(): exception.getCode();
String message = StrUtil.isNotEmpty(exception.getMessage()) ? exception.getMessage() : "业务异常";
return GlobalResult.error( code, exception.getMessage(), message);
}
/**

Loading…
Cancel
Save