mirror of https://gitee.com/y_project/RuoYi.git
update ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java.
当访问异常时,增加对请求URL的记录,便于排查问题pull/301/head
parent
b016f3a47f
commit
7528a595fc
|
@ -47,21 +47,23 @@ public class GlobalExceptionHandler
|
|||
/**
|
||||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler({ HttpRequestMethodNotSupportedException.class })
|
||||
public AjaxResult handleException(HttpRequestMethodNotSupportedException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error("不支持' " + e.getMethod() + "'请求");
|
||||
@ExceptionHandler({HttpRequestMethodNotSupportedException.class})
|
||||
public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod());
|
||||
log.error(msg, e);
|
||||
return AjaxResult.error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public AjaxResult notFount(RuntimeException e)
|
||||
{
|
||||
log.error("运行时异常:", e);
|
||||
return AjaxResult.error("运行时异常:" + e.getMessage());
|
||||
public AjaxResult notFount(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
String msg = String.format("访问的URL[%s]发生异常%s", requestURI, e.getMessage());
|
||||
log.error(msg, e);
|
||||
return AjaxResult.error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue