-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nicer traceback formatting #2667
Conversation
…id escaping in style element and add new styles.
…module niceback to do the tracebacks.
Hmm, not possible to make draft PR to another PR? Anyway, all be reminded that this is very explosive draft code build on top of another draft PR. |
Not sure about adding two deps for this right now. Also, changing travebacks is a fairly opinionated item. That to me feels more like something that should be in sanic-ext, with this focusing more on adding the styling changes. |
…rint also headers, and for other than 500 errors as well. 500 error message text UX workaround.
Yes, definitely not going to push it, but I might leave it floating around for a bit later should there be interest. I don't see it living in sanic-ext because either you get better exception handling in default install or you never get one (I have many years of prior experience with niceback, trying to get Jupyter Notebook, Google Colab and others to use it but not even regular data scientists do). I made some cleanup today. The last night thing was about 15 minutes quick adoption (after some hours porting other parts of the old error page). Instead of spending more time porting the TB formatter, using niceback was essentially just one function call. Long term plan: few minor improvements on niceback (that I've done today, maybe a bit more needed), get that moved to sanic-org as well, and change the name. Turns out that all Internet search engines search for Nickelback when you want Niceback, and even when forced give you physiotherapy instead, so the name clearly needs to be changed. |
With the cleanup done today, you don't get the two white tabs as shown in the screenshot above, in that situation. Also the Request object is hidden in variable inspector because it provided no information not already known. Thus, for a simple bug you get very simplified output that directly points out what happened and where. For more complicated cases it still prints tabs for the full call chain (with variable inspector on each tab), and "the above exception occurred after catching ..." kind of thing as well (try causing a 404 error with |
Real quick thought I've had, then I'll respond in more detail when I'm at my computer. Let's keep the formatting in, but only conditionally. We have a note that says you can have nicer travebacks if you install this. Like how we deal with Jinja. You are not required to download it, but we support it if you do. |
* Add color sections for dark mode * Tweak colors for light mode * Tweak colors for dark mode * Remove tab styling * Remove forced hanging emoji from error header * Add padding for main container so text doesn’t touch screen boundary * invalid text justify css * Tweak color scheme for dark themes * Add margins for h3. Probably should be done in the tracerite package. * Add tracerite tab color with new sanic-tab variable. * Soften lightmode text color * Define sanic-background, sanic-text as top-level colors. Restructure color schemes to top of definition. * Define highlight and tab colors as variables * Add tab hover shadow definition. Intended to have better hover accents for light theme. * Ensure sanic brand color be the same in dark mode. * Add header background, change all dark theme grays to neutral grays. * Switch blue to code block orange in sanic docs. Add sanic highlight override. Add darker sanic background (111) as option but in the comments so we can switch back if need be. * Add sanic id to top level document. * Use hsl and rgba for dark themed background so that they can be easily changed and nudged. * Change colors to Adam’s preferences. * Remove important from css after adding sanic as id, * Remove remnants of “important” for pre and code tags. Add Meslo in font.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2667 +/- ##
=============================================
- Coverage 88.716% 88.642% -0.075%
=============================================
Files 87 87
Lines 6851 6815 -36
Branches 1177 1171 -6
=============================================
- Hits 6078 6041 -37
- Misses 532 533 +1
Partials 241 241
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I am excited to get this in. Just a few questions. Also, I am proposing a simpler color scheme here: #2703. Also it corrects a couple items around debug mode, and adds a few helpful links when debug=True.
* tracerite var colors * Simplified parse_content_header escaping (#2707) * Move comments, darken bg color, move debug links to contextmanager * Lineup H2s * Make pretty --------- Co-authored-by: L. Kärkkäinen <[email protected]>
Shinier error pages for Sanic, using the sanic-org/tracerite module for traceback formatting and the new BasePage layout merged in #2662.
Any exception in an app, while running Sanic in debug mode gives a formatted traceback:
An attempt is made to show only the relevant parts of call chains and exception chains, pointing to where the error is in user code instead, but other details are available under tab headers (e.g. Sanic.handle_request in the above screenshot - but the current version would hide that entirely and the style has also changed since).