From f4443a83d80bf592042ca86d5737861cdf986d16 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 22:41:02 +0000 Subject: [PATCH] Add Exception schema --- schemas/exception.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/schemas/exception.py b/schemas/exception.py index 9be2beb..95c1818 100644 --- a/schemas/exception.py +++ b/schemas/exception.py @@ -4,12 +4,11 @@ from datetime import datetime from uuid import UUID class ExceptionBase(BaseModel): - error_code: str = Field(..., max_length=50) - error_message: str = Field(..., max_length=255) - stack_trace: Optional[str] = Field(None) - endpoint: str = Field(..., max_length=100) - method: str = Field(..., max_length=10) - request_data: Optional[str] = Field(None) + error_code: str = Field(..., description="Error code identifier") + error_message: str = Field(..., description="Detailed error message") + stack_trace: Optional[str] = Field(None, description="Stack trace of the error") + endpoint: str = Field(..., description="API endpoint where error occurred") + request_data: Optional[str] = Field(None, description="Request data when error occurred") class ExceptionCreate(ExceptionBase): class Config: @@ -19,8 +18,7 @@ class ExceptionCreate(ExceptionBase): "error_message": "Internal Server Error", "stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')", "endpoint": "/api/v1/users", - "method": "POST", - "request_data": '{"username": "john_doe", "email": "john@example.com"}' + "request_data": "{'user_id': '123', 'action': 'update'}" } } @@ -37,8 +35,7 @@ class Exception(ExceptionBase): "error_message": "Internal Server Error", "stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')", "endpoint": "/api/v1/users", - "method": "POST", - "request_data": '{"username": "john_doe", "email": "john@example.com"}', - "created_at": "2023-01-01T12:00:00" + "request_data": "{'user_id': '123', 'action': 'update'}", + "created_at": "2023-01-01T00:00:00" } } \ No newline at end of file