mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 12:46:39 +00:00
feat: add more errors processing
This commit is contained in:
parent
cf3e6fe39e
commit
0700e2285f
|
@ -41,6 +41,7 @@ from selfprivacy_api.repositories.users.exceptions import (
|
|||
)
|
||||
from selfprivacy_api.repositories.users.exceptions_kanidm import (
|
||||
KanidmDidNotReturnAdminPassword,
|
||||
KanidmQueryError,
|
||||
KanidmReturnEmptyResponse,
|
||||
KanidmReturnUnknownResponseType,
|
||||
)
|
||||
|
@ -102,6 +103,7 @@ class UsersMutations:
|
|||
KanidmDidNotReturnAdminPassword,
|
||||
KanidmReturnUnknownResponseType,
|
||||
KanidmReturnEmptyResponse,
|
||||
KanidmQueryError,
|
||||
) as error:
|
||||
return return_failed_mutation_return(
|
||||
message=error.get_error_message(),
|
||||
|
@ -148,7 +150,7 @@ class UsersMutations:
|
|||
code=400,
|
||||
message=error.get_error_message(),
|
||||
)
|
||||
except KanidmDidNotReturnAdminPassword as error:
|
||||
except (KanidmDidNotReturnAdminPassword, KanidmQueryError) as error:
|
||||
return GenericMutationReturn(
|
||||
success=False,
|
||||
code=500,
|
||||
|
@ -177,6 +179,7 @@ class UsersMutations:
|
|||
KanidmDidNotReturnAdminPassword,
|
||||
KanidmReturnUnknownResponseType,
|
||||
KanidmReturnEmptyResponse,
|
||||
KanidmQueryError,
|
||||
) as error:
|
||||
return return_failed_mutation_return(
|
||||
message=error.get_error_message(),
|
||||
|
@ -268,6 +271,7 @@ class UsersMutations:
|
|||
RootIsNotAvailableForModification,
|
||||
KanidmReturnUnknownResponseType,
|
||||
KanidmReturnEmptyResponse,
|
||||
KanidmQueryError,
|
||||
) as error:
|
||||
return PasswordResetLinkReturn(
|
||||
success=False,
|
||||
|
|
|
@ -10,6 +10,10 @@ from selfprivacy_api.graphql.common_types.user import (
|
|||
get_users,
|
||||
)
|
||||
from selfprivacy_api.graphql import IsAuthenticated
|
||||
from selfprivacy_api.repositories.users.exceptions_kanidm import (
|
||||
KanidmReturnUnknownResponseType,
|
||||
KanidmReturnEmptyResponse,
|
||||
)
|
||||
|
||||
|
||||
@strawberry.type
|
||||
|
@ -17,7 +21,10 @@ class Users:
|
|||
@strawberry.field(permission_classes=[IsAuthenticated])
|
||||
def get_user(self, username: str) -> typing.Optional[User]:
|
||||
"""Get users"""
|
||||
return get_user_by_username(username)
|
||||
try:
|
||||
return get_user_by_username(username)
|
||||
except (KanidmReturnUnknownResponseType, KanidmReturnEmptyResponse):
|
||||
pass # TODO what todo ??
|
||||
|
||||
all_users: typing.List[User] = strawberry.field(
|
||||
permission_classes=[IsAuthenticated], resolver=get_users
|
||||
|
|
Loading…
Reference in a new issue