Pre Merge pull request !581 from soulmate/dev

This commit is contained in:
soulmate 2024-08-27 16:29:27 +00:00 committed by Gitee
commit afb931637a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -156,4 +156,17 @@ public class GlobalExceptionHandler {
return R.fail(message); return R.fail(message);
} }
/**
* 拦截空指针异常异常
*/
@ExceptionHandler(NullPointerException.class)
public R<Void> handleNullPointerException(NullPointerException e) {
log.error(e.getMessage());
String message = e.getMessage();
if (message.contains("because \"loginUser\" is null")) {
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
}
return R.fail(message);
}
} }