Pre Merge pull request !171 from runphp/N/A

This commit is contained in:
runphp 2022-07-12 10:22:30 +00:00 committed by Gitee
commit 2796e62fc8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 12 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import com.ruoyi.common.core.constant.HttpStatus;
import com.ruoyi.common.core.exception.DemoModeException;
import com.ruoyi.common.core.exception.InnerAuthException;
@ -61,6 +62,17 @@ public class GlobalExceptionHandler
return AjaxResult.error(e.getMessage());
}
/**
* 请求参数类型错误
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',参数'{}'类型错误", requestURI, e.getName());
return AjaxResult.error(e.getMessage());
}
/**
* 业务异常
*/