In HttpException response showing status code at the beginning. #11591
-
First Check
Commit to Help
Example Coderaise HTTPException(status_code=404, detail="No transaction found for your request") Descriptionin fastapi httpexception i get exception like this "404: No transaction found for your request" how to avoid that status code at the beginning of the http exception response Operating SystemWindows Operating System DetailsNo response FastAPI Version0.109.1 Pydantic Version2.0.3 Python Version3.11 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
YuriiMotov
May 17, 2024
Replies: 1 comment
-
You can create your own exception class, inherit it from
Then use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create your own exception class, inherit it from
HTTPException
and redefine__str__
method as you need:Then use
MyHTTPException
instead ofHTTPException