mirror of https://gitee.com/y_project/RuoYi.git
commit
4ab671f211
|
@ -47,21 +47,23 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue