|
|
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
|
|
import org.springframework.web.multipart.MultipartException;
|
|
|
|
|
|
@RestControllerAdvice
|
|
|
@@ -32,6 +33,12 @@ public class GlobalExceptionHandler {
|
|
|
return Result.error(405, "请求方法不支持,本平台接口统一使用POST");
|
|
|
}
|
|
|
|
|
|
+ @ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
|
|
+ public Result<Void> handleTypeMismatch(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
|
|
|
+ log.warn("路径参数类型错误: uri={}, error={}", request.getRequestURI(), e.getMessage());
|
|
|
+ return Result.error(400, "请求参数格式错误");
|
|
|
+ }
|
|
|
+
|
|
|
@ExceptionHandler(Exception.class)
|
|
|
public Result<Void> handleException(Exception e, HttpServletRequest request) {
|
|
|
log.error("未捕获异常: {} - {} | uri={}", e.getClass().getName(), e.getMessage(), request.getRequestURI(), e);
|