Better exception formatting by tracerite #1865
Unanswered
LeoVasanko
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Example Code
# Not relevantDescription
I am looking to integrate Tracerite to FastAPI and consequently to this project, because it provides by far the best tracebacks that anyone has implemented for Python. The module formats for CLI, with colors, graphics and variable inspector similar to Typer's rich formatting, but also formats for HTML. Unlike others, it provides short to-the-point traceback with the relevant information in chronological order.
Wiring it up for HTML tracebacks on FastAPI is straight forward replacing Starlette ServerErrorMiddleware, but we also want to handle tracebacks on CLI, also during server startup, specifically including syntax errors and other such things that would fail early while loading the app. And this is where I discovered Typer as it is already wired to do that in the FastAPI stack.
For the console Tracerite hooks up sys.excepthook and also logging.exception. Typer is also grabbing the excepthook, but I see we could disable that from FastAPI side. Ideally we'd also hook somewhere between uvicorn.run and Config.load_app, such that we can handle those import and syntax errors, but there doesn't appear to be suitable hooks for this.
I will be making PR(s) on this, but I would like to have your insights first on where it would best be plugged in, and to which project I should make the PR to avoid monkey patching.
Hopefully you can shed some light on this so that I won't be working blindly.
Operating System
Other
Operating System Details
No response
Project Version
0.26.8
Python Version
No response
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions