Skip to content

Commit 5fbca04

Browse files
committed
Improvements to client.user_info() implementation
1 parent 9c834e0 commit 5fbca04

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fairgraph/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,15 @@ def user_info(self) -> Dict[str, Any]:
508508
This information is that associated with the authorization token used.
509509
"""
510510
if self._user_info is None:
511-
try:
512-
self._user_info = self._kg_client.users.my_info().data
513-
except KeyError:
514-
self._user_info is None
511+
response = self._kg_client.users.my_info()
512+
if response.data:
513+
self._user_info = response.data
514+
elif response.error.code == 401:
515+
raise AuthenticationError()
516+
elif response.error.code == 403:
517+
raise AuthorizationError()
518+
else:
519+
raise Exception(response.error)
515520
return self._user_info
516521

517522
def spaces(

0 commit comments

Comments
 (0)