1.全局异常处理类
package com.example.exception.handler;
import com.example.exception.entity.HttpResult;
import com.example.exception.exception.CheckException;
import com.example.exception.exception.OperationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
/**
* 全局异常处理类
*/
@Component
@RestControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
/**
* 处理 CheckException 异常
* @param e 参数校验类异常
* @return HttpResult.fail
*/
&