As is the general case with FastAPI, if a request doesn't correspond to the Pydantic model we get a 422 Unprocessable entity
error and the response is visible on the client side.
Is there a way to get the log this on the server side?
example:
class Model(BaseModel):
id: int
name: str
surname: str
@app.post("/", status_code=status.HTTP_201_CREATED)
async def create_student(student:Model):
#Some functionality being done
pass
In the above case if the request is
{
"name":"John",
"surname":"Smith"
}
The fastapi throws an error on client side with status code 422. Is it possible to catch the error in the server side and write some logs as to what was the input request etc.