!301 当URL请求异常时,增加对请求URL的记录,便于排查问题

Merge pull request !301 from 无名丶小辈/master
pull/307/head
若依 2021-07-09 02:34:24 +00:00 committed by Gitee
commit 4ab671f211
1 changed files with 11 additions and 9 deletions

View File

@ -48,20 +48,22 @@ public class GlobalExceptionHandler
* *
*/ */
@ExceptionHandler({HttpRequestMethodNotSupportedException.class}) @ExceptionHandler({HttpRequestMethodNotSupportedException.class})
public AjaxResult handleException(HttpRequestMethodNotSupportedException e) public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
{ String requestURI = request.getRequestURI();
log.error(e.getMessage(), e); String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod());
return AjaxResult.error("不支持' " + e.getMethod() + "'请求"); log.error(msg, e);
return AjaxResult.error(msg);
} }
/** /**
* *
*/ */
@ExceptionHandler(RuntimeException.class) @ExceptionHandler(RuntimeException.class)
public AjaxResult notFount(RuntimeException e) public AjaxResult notFount(RuntimeException e, HttpServletRequest request) {
{ String requestURI = request.getRequestURI();
log.error("运行时异常:", e); String msg = String.format("访问的URL[%s]发生异常%s", requestURI, e.getMessage());
return AjaxResult.error("运行时异常:" + e.getMessage()); log.error(msg, e);
return AjaxResult.error(msg);
} }
/** /**