增加错误类型
This commit is contained in:
parent
c473eda424
commit
8c81457fd7
|
@ -2,6 +2,7 @@ package com.isu.gaswellwatch.config;
|
|||
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.filter.SaServletFilter;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
|
@ -49,7 +50,12 @@ public class SaTokenConfigure {
|
|||
});
|
||||
})
|
||||
// 异常处理方法:每次setAuth函数出现异常时进入
|
||||
.setError(e -> SaResult.error(e.getMessage()))
|
||||
.setError(e -> {
|
||||
if(e instanceof NotLoginException){
|
||||
return SaResult.error(UserConstant.NOT_LOGIN_MSG).setCode(UserConstant.NOT_LOGIN_CODE);
|
||||
}
|
||||
return SaResult.error(e.getMessage());
|
||||
})
|
||||
|
||||
// 前置函数:在每次认证函数之前执行(BeforeAuth 不受 includeList 与 excludeList 的限制,所有请求都会进入)
|
||||
.setBeforeAuth(obj -> {
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.isu.gaswellwatch.constants;
|
|||
|
||||
public class UserConstant {
|
||||
public static final String TOKEN_SESSION = "Token-Session";
|
||||
public static final Integer NOT_LOGIN_CODE = 501;
|
||||
public static final String NOT_LOGIN_MSG = "当前状态未登录,请先登录";
|
||||
public static final String MENU_LIST_PREFIX = "gwwMenuList:";
|
||||
public static final String DEFAULT_PASSWORD = "123456";
|
||||
public static final String NORMAL = "1";
|
||||
|
|
|
@ -124,5 +124,4 @@ public class GlobalExceptionHandler {
|
|||
log.error("请求接口地址:{},触发异常类:{}, 异常消息:{}", request.getRequestURI(), e.getClass(), rawMsg);
|
||||
return Response.failed(translationMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue