额外异常

This commit is contained in:
2025-11-14 18:29:21 +08:00
parent 8ee1d07833
commit 4d7a706711

View File

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.resource.NoResourceFoundException;
import java.util.List;
@@ -78,6 +79,14 @@ public class CzgControllerAdvice {
return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), message);
}
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
public CzgResult<Object> methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException ex) {
log.error("参数类型转换异常:{}", ex.getMessage());
return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), ex.getMessage());
}
/**
* 处理自定义异常
*/