
top.lshaci.framework.web.handler.exception.GlobalExceptionHandler Maven / Gradle / Ivy
package top.lshaci.framework.web.handler.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import top.lshaci.framework.common.exception.BaseException;
import top.lshaci.framework.web.enums.ErrorCode;
import top.lshaci.framework.web.model.JsonResponse;
import javax.servlet.http.HttpServletRequest;
/**
* Global exception handler
*
* 0.0.4: Add method argumentExceptionHandler
*
* @author lshaci
* @since 0.0.3
* @version 0.0.4
*/
@Slf4j
@RestController
@ControllerAdvice
public class GlobalExceptionHandler {
/**
* System exception log message
*/
private static final String SYSTEM_EXCEPTION = "System anomaly!";
/**
* Argument exception log message
*/
private final static String FIELD = "字段:";
/**
* Base exception handler
*
* @param req the http servlet request
* @param e the exception
* @return json response
*/
@ExceptionHandler(BaseException.class)
public JsonResponse
© 2015 - 2025 Weber Informatics LLC | Privacy Policy