mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 20:56: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 (
|
from selfprivacy_api.repositories.users.exceptions_kanidm import (
|
||||||
KanidmDidNotReturnAdminPassword,
|
KanidmDidNotReturnAdminPassword,
|
||||||
|
KanidmQueryError,
|
||||||
KanidmReturnEmptyResponse,
|
KanidmReturnEmptyResponse,
|
||||||
KanidmReturnUnknownResponseType,
|
KanidmReturnUnknownResponseType,
|
||||||
)
|
)
|
||||||
|
@ -102,6 +103,7 @@ class UsersMutations:
|
||||||
KanidmDidNotReturnAdminPassword,
|
KanidmDidNotReturnAdminPassword,
|
||||||
KanidmReturnUnknownResponseType,
|
KanidmReturnUnknownResponseType,
|
||||||
KanidmReturnEmptyResponse,
|
KanidmReturnEmptyResponse,
|
||||||
|
KanidmQueryError,
|
||||||
) as error:
|
) as error:
|
||||||
return return_failed_mutation_return(
|
return return_failed_mutation_return(
|
||||||
message=error.get_error_message(),
|
message=error.get_error_message(),
|
||||||
|
@ -148,7 +150,7 @@ class UsersMutations:
|
||||||
code=400,
|
code=400,
|
||||||
message=error.get_error_message(),
|
message=error.get_error_message(),
|
||||||
)
|
)
|
||||||
except KanidmDidNotReturnAdminPassword as error:
|
except (KanidmDidNotReturnAdminPassword, KanidmQueryError) as error:
|
||||||
return GenericMutationReturn(
|
return GenericMutationReturn(
|
||||||
success=False,
|
success=False,
|
||||||
code=500,
|
code=500,
|
||||||
|
@ -177,6 +179,7 @@ class UsersMutations:
|
||||||
KanidmDidNotReturnAdminPassword,
|
KanidmDidNotReturnAdminPassword,
|
||||||
KanidmReturnUnknownResponseType,
|
KanidmReturnUnknownResponseType,
|
||||||
KanidmReturnEmptyResponse,
|
KanidmReturnEmptyResponse,
|
||||||
|
KanidmQueryError,
|
||||||
) as error:
|
) as error:
|
||||||
return return_failed_mutation_return(
|
return return_failed_mutation_return(
|
||||||
message=error.get_error_message(),
|
message=error.get_error_message(),
|
||||||
|
@ -268,6 +271,7 @@ class UsersMutations:
|
||||||
RootIsNotAvailableForModification,
|
RootIsNotAvailableForModification,
|
||||||
KanidmReturnUnknownResponseType,
|
KanidmReturnUnknownResponseType,
|
||||||
KanidmReturnEmptyResponse,
|
KanidmReturnEmptyResponse,
|
||||||
|
KanidmQueryError,
|
||||||
) as error:
|
) as error:
|
||||||
return PasswordResetLinkReturn(
|
return PasswordResetLinkReturn(
|
||||||
success=False,
|
success=False,
|
||||||
|
|
|
@ -10,6 +10,10 @@ from selfprivacy_api.graphql.common_types.user import (
|
||||||
get_users,
|
get_users,
|
||||||
)
|
)
|
||||||
from selfprivacy_api.graphql import IsAuthenticated
|
from selfprivacy_api.graphql import IsAuthenticated
|
||||||
|
from selfprivacy_api.repositories.users.exceptions_kanidm import (
|
||||||
|
KanidmReturnUnknownResponseType,
|
||||||
|
KanidmReturnEmptyResponse,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
|
@ -17,7 +21,10 @@ class Users:
|
||||||
@strawberry.field(permission_classes=[IsAuthenticated])
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
||||||
def get_user(self, username: str) -> typing.Optional[User]:
|
def get_user(self, username: str) -> typing.Optional[User]:
|
||||||
"""Get users"""
|
"""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(
|
all_users: typing.List[User] = strawberry.field(
|
||||||
permission_classes=[IsAuthenticated], resolver=get_users
|
permission_classes=[IsAuthenticated], resolver=get_users
|
||||||
|
|
Loading…
Reference in a new issue