
top.lshaci.framework.web.exception.handler.GlobalExceptionHandler Maven / Gradle / Ivy
package top.lshaci.framework.web.exception.handler;
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.common.model.JsonResponse;
import top.lshaci.framework.web.model.ExceptionMessage;
import top.lshaci.framework.web.utils.GlobalExceptionUtils;
/**
* Global exception handler
*
* 0.0.4: Add method argumentExceptionHandler
* 1.0.4: 使用GlobalExceptionUtils来获取自定义的异常消息
*
* @author lshaci
* @since 0.0.3
* @version 1.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 e the exception
* @return json response
*/
@ExceptionHandler(BaseException.class)
public JsonResponse
© 2015 - 2025 Weber Informatics LLC | Privacy Policy