реализация второй лабы

This commit is contained in:
Ванек
2026-10-22 17:16:01 +03:00
parent 9961362555
commit 0dfbfe35f8
43 changed files with 5114 additions and 337 deletions
+3 -2
View File
@@ -5,11 +5,12 @@ from fastapi.responses import JSONResponse
class ApiError(Exception):
def __init__(self, status: int, code: str, message: str):
def __init__(self, status: int, code: str, message: str, headers=None):
super().__init__(message)
self.status = status
self.code = code
self.message = message
self.headers = headers or {}
def error_response(request: Request, error: ApiError):
@@ -22,5 +23,5 @@ def error_response(request: Request, error: ApiError):
"request_id": request.state.request_id,
}
},
headers={"X-Request-Id": request.state.request_id},
headers={"X-Request-Id": request.state.request_id, **error.headers},
)