整合jwt

This commit is contained in:
2022-09-21 17:50:01 +08:00
parent 98deffce46
commit b623970db8
9 changed files with 79 additions and 114 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.nl.exception.handler;
import cn.dev33.satoken.exception.NotLoginException;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.exception.EntityExistException;
@@ -59,6 +60,19 @@ public class GlobalExceptionHandler {
// return buildResponseEntity(ApiError.error(message));
// }
/**
* token 无效的异常拦截
* @param e
* @return
*/
@ExceptionHandler(value = NotLoginException.class)
public ResponseEntity<ApiError> notLoginException(Exception e) {
// e.printStackTrace();
log.error(ThrowableUtil.getStackTrace(e));
return buildResponseEntity(ApiError.error("Token 无效"));
}
/**
* 处理自定义异常
*/