Add Exception schema
This commit is contained in:
parent
fa5443facf
commit
f4443a83d8
@ -4,12 +4,11 @@ from datetime import datetime
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
class ExceptionBase(BaseModel):
|
class ExceptionBase(BaseModel):
|
||||||
error_code: str = Field(..., max_length=50)
|
error_code: str = Field(..., description="Error code identifier")
|
||||||
error_message: str = Field(..., max_length=255)
|
error_message: str = Field(..., description="Detailed error message")
|
||||||
stack_trace: Optional[str] = Field(None)
|
stack_trace: Optional[str] = Field(None, description="Stack trace of the error")
|
||||||
endpoint: str = Field(..., max_length=100)
|
endpoint: str = Field(..., description="API endpoint where error occurred")
|
||||||
method: str = Field(..., max_length=10)
|
request_data: Optional[str] = Field(None, description="Request data when error occurred")
|
||||||
request_data: Optional[str] = Field(None)
|
|
||||||
|
|
||||||
class ExceptionCreate(ExceptionBase):
|
class ExceptionCreate(ExceptionBase):
|
||||||
class Config:
|
class Config:
|
||||||
@ -19,8 +18,7 @@ class ExceptionCreate(ExceptionBase):
|
|||||||
"error_message": "Internal Server Error",
|
"error_message": "Internal Server Error",
|
||||||
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
||||||
"endpoint": "/api/v1/users",
|
"endpoint": "/api/v1/users",
|
||||||
"method": "POST",
|
"request_data": "{'user_id': '123', 'action': 'update'}"
|
||||||
"request_data": '{"username": "john_doe", "email": "john@example.com"}'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +35,7 @@ class Exception(ExceptionBase):
|
|||||||
"error_message": "Internal Server Error",
|
"error_message": "Internal Server Error",
|
||||||
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
||||||
"endpoint": "/api/v1/users",
|
"endpoint": "/api/v1/users",
|
||||||
"method": "POST",
|
"request_data": "{'user_id': '123', 'action': 'update'}",
|
||||||
"request_data": '{"username": "john_doe", "email": "john@example.com"}',
|
"created_at": "2023-01-01T00:00:00"
|
||||||
"created_at": "2023-01-01T12:00:00"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user