You've already forked FrameTour-BE
参数错误打印错误请求地址方便排查
This commit is contained in:
@ -2,6 +2,7 @@ package com.ycwl.basic.exception;
|
|||||||
|
|
||||||
import com.ycwl.basic.enums.BizCodeEnum;
|
import com.ycwl.basic.enums.BizCodeEnum;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
|
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +57,12 @@ public class CustomExceptionHandle {
|
|||||||
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||||
return ApiResponse.buildResponse(bizException.getCode(), bizException.getMsg());
|
return ApiResponse.buildResponse(bizException.getCode(), bizException.getMsg());
|
||||||
}
|
}
|
||||||
|
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
|
||||||
|
public ApiResponse<String> handle(HttpServletRequest request, HttpServletResponse response, MethodArgumentTypeMismatchException exception) {
|
||||||
|
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||||
|
LOGGER.error("参数错误 -> 请求地址:{},请求方式:{}", request.getRequestURI(), request.getMethod());
|
||||||
|
return ApiResponse.buildResponse(5000, "参数错误!");
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(value =IOException.class)
|
@ExceptionHandler(value =IOException.class)
|
||||||
public ApiResponse<String> handle(HttpServletResponse response, IOException e) {
|
public ApiResponse<String> handle(HttpServletResponse response, IOException e) {
|
||||||
|
Reference in New Issue
Block a user