update 更新全局异常响应

This commit is contained in:
疯狂的狮子li 2022-01-28 19:57:19 +08:00
parent eefe3a9c6e
commit ce9e033551

View File

@ -34,7 +34,7 @@ public class GlobalExceptionHandler {
* 权限码异常 * 权限码异常
*/ */
@ExceptionHandler(NotPermissionException.class) @ExceptionHandler(NotPermissionException.class)
public AjaxResult handleNotPermissionException(NotPermissionException e, HttpServletRequest request) { public AjaxResult<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
String requestURI = request.getRequestURI(); String requestURI = request.getRequestURI();
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage()); log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权"); return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
@ -44,7 +44,7 @@ public class GlobalExceptionHandler {
* 角色权限异常 * 角色权限异常
*/ */
@ExceptionHandler(NotRoleException.class) @ExceptionHandler(NotRoleException.class)
public AjaxResult handleNotRoleException(NotRoleException e, HttpServletRequest request) { public AjaxResult<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
String requestURI = request.getRequestURI(); String requestURI = request.getRequestURI();
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage()); log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权"); return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
@ -54,7 +54,7 @@ public class GlobalExceptionHandler {
* 认证失败 * 认证失败
*/ */
@ExceptionHandler(NotLoginException.class) @ExceptionHandler(NotLoginException.class)
public AjaxResult handleNotLoginException(NotLoginException e, HttpServletRequest request) { public AjaxResult<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
String requestURI = request.getRequestURI(); String requestURI = request.getRequestURI();
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage()); log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源"); return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");