diff --git a/admin/services.py b/admin/services.py index ec98b10c533..2c8eaaf7cbb 100644 --- a/admin/services.py +++ b/admin/services.py @@ -8,6 +8,7 @@ from api.db.services.knowledgebase_service import KnowledgebaseService from api.utils.crypt import decrypt from api.utils import health_utils + from api.common.exceptions import AdminException, UserAlreadyExistsError, UserNotFoundError from config import SERVICE_CONFIGS diff --git a/api/common/exceptions.py b/api/common/exceptions.py index 5e3021b418a..5ce0e0bc211 100644 --- a/api/common/exceptions.py +++ b/api/common/exceptions.py @@ -1,17 +1,21 @@ class AdminException(Exception): def __init__(self, message, code=400): super().__init__(message) + self.type = "admin" self.code = code self.message = message + class UserNotFoundError(AdminException): def __init__(self, username): super().__init__(f"User '{username}' not found", 404) + class UserAlreadyExistsError(AdminException): def __init__(self, username): super().__init__(f"User '{username}' already exists", 409) + class CannotDeleteAdminError(AdminException): def __init__(self): super().__init__("Cannot delete admin account", 403) \ No newline at end of file