fix: error exception

This commit is contained in:
dettlaff 2024-11-11 20:07:34 +04:00
parent b6a4758c9b
commit c056540578

View file

@ -15,8 +15,6 @@ TEST_TOKEN = """eyJhbGciOiJFUzI1NiIsImtpZCI6IjVkNDUyNzdmZWUxY2UzZmNkMTViZDhkZjE3
class KanidmQueryError(Exception): class KanidmQueryError(Exception):
"""Error occurred during kanidm query""" """Error occurred during kanidm query"""
error: str
class KanidmUserRepository(AbstractUserRepository): class KanidmUserRepository(AbstractUserRepository):
@staticmethod @staticmethod
@ -37,13 +35,13 @@ class KanidmUserRepository(AbstractUserRepository):
if response.status_code != 200: if response.status_code != 200:
error_text = getattr(response, "text", "No response error was found...") error_text = getattr(response, "text", "No response error was found...")
raise KanidmQueryError( raise KanidmQueryError(
error=f"Kanidm returned {response.status_code} unexpected HTTP status code. Error: {error_text}." f"Kanidm returned {response.status_code} unexpected HTTP status code. Error: {error_text}."
) )
json = response.json() json = response.json()
return json["data"] return json["data"]
except Exception as error: except Exception as error:
raise KanidmQueryError(error=f"Kanidm request failed! Error: {str(error)}") raise KanidmQueryError(f"Kanidm request failed! Error: {str(error)}")
@staticmethod @staticmethod
def create_user(username: str, password: str): def create_user(username: str, password: str):