events auth repair

This commit is contained in:
2025-01-16 22:35:49 +03:00
parent 426b69b33c
commit 61229cb761
23 changed files with 945 additions and 754 deletions

View File

@@ -56,6 +56,7 @@ def handle_mongo_errors(func: Callable) -> Callable:
lang="en",
error_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
loc=get_line_number_for_error(),
sys_msg=str(e),
)
return wrapper

View File

@@ -7,6 +7,7 @@ operations and password-related functionality.
from typing import Any, Dict, Optional
from fastapi import HTTPException, status
from ApiLibrary.common.line_number import get_line_number_for_error
from ErrorHandlers.ErrorHandlers.api_exc_handler import HTTPExceptionApi
@@ -26,9 +27,11 @@ class MongoBaseException(Exception):
def to_http_exception(self) -> HTTPException:
"""Convert to FastAPI HTTPException."""
return HTTPExceptionApi(
raise HTTPExceptionApi(
lang="en",
error_code=self.status_code,
loc=get_line_number_for_error(),
sys_msg=self.message,
)

View File

@@ -39,24 +39,28 @@ def handle_mongo_errors(func):
error_code="HTTP_503_SERVICE_UNAVAILABLE",
lang="en",
loc=get_line_number_for_error(),
sys_msg="MongoDB connection failed",
)
except ServerSelectionTimeoutError:
raise HTTPExceptionApi(
error_code="HTTP_504_GATEWAY_TIMEOUT",
lang="en",
loc=get_line_number_for_error(),
sys_msg="MongoDB connection timed out",
)
except OperationFailure as e:
raise HTTPExceptionApi(
error_code="HTTP_400_BAD_REQUEST",
lang="en",
loc=get_line_number_for_error(),
sys_msg=str(e),
)
except PyMongoError as e:
raise HTTPExceptionApi(
error_code="HTTP_500_INTERNAL_SERVER_ERROR",
lang="en",
loc=get_line_number_for_error(),
sys_msg=str(e),
)
return wrapper