Comments (9)
OT:
That's really good, I've been wanting something that distinguishes visually between the users code and the systems code for a while.
from better-exceptions.
If this can be implemented elegantly then I'm all for it. :)
from better-exceptions.
Colorization of file / line / function would be great in my opinion. This seems related to what was proposed in #32 about implementing tbvaccine's enhancements.
The complications arise from the fact that to color the stacktrace like this, it must be parsed once it has been formatted using traceback.format_list()
. I avoid you technical details, but for having implemented it in a personal fork, I can say that this is not a very elegant solution. But it is possible, of course.
Improved error messages is a whole other beast. There seems to be a lot of cases to deal with.
from better-exceptions.
Wow that is really cool, it looks like he has a marker to mark the current directory and files beneath as the only files that get colorized.
from better-exceptions.
Yes, this is what is done here.
It iterates through the lines of the formatted exception, if the line matches the file regex, it extracts the filename and checks heuristically if it belongs to the user or not.
from better-exceptions.
Well, the obvious way is to use a regex substitution on the formatted stacktrace. That's not very elegant. But I can't see any other solution.
from better-exceptions.
I've been wanting something that distinguishes visually between the users code and the systems code for a while.
This would be really helpful.
from better-exceptions.
Is tbvacine a completely different project, or a fork of this, at first I was having trouble working out how the code relates, but I guess it's to show a possible implementation ?
finding the file, line and function probably wants to be separate from the actual colouring - to make all sorts of things easier (e.g. different colour themes, or adding links to files).
Irrespective of how colourization would work, any idea where in the code this should go ?
from better-exceptions.
Is tbvacine a completely different project, or a fork of this
Entirely different, no relation.
Irrespective of how colourization would work, any idea where in the code this should go ?
If we're talking about the image OP provided (were elements of the traceback are very clearly distinguished), I would imagine somewhere near the existing color support. If you want to formalize how the coloring system works, then go for it. A lot of the existing logic is kind of hairy since some of it has been copied from the internals, and the original implementation was extracted from a programming language compiler I was writing at the time (meaning it wasn't intended to be its own package at first, so 'cleanliness' wasn't priority no. 1 π ).
Feel free to take some liberties.
What if better-exceptions had a feature that would read the error message, read the code that committed it and return a more easily understood error message and a quick one or two line code snippet to show you what isn't allowed.
I actually think this is out of scope for this package. As the OP has described it (unless I'm mistaken), they're asking for replacing exceptions with an entirely new format that is "newbie friendly", giving a succinct explanation of the problem.
Not only is that really hard to achieve, it's not something I'd ever dare mess with - tracebacks are verbose for a reason. They aren't there to help you learn Python, they're there to help you fix a problem with your code.
Highlighting important traceback elements is a π, replacing tracebacks altogether with something watered down is a non-starter for me and thus a π.
from better-exceptions.
Related Issues (20)
- activate extension only when BETTER_EXCEPTIONS has true-like value: '1', 'on' or 'yes' HOT 2
- FileNotFoundError on PyPy HOT 4
- TERM setting of tmux-256color vs screen⦠HOT 3
- Not working with ~/.python_history
- threading.excepthook new in python 3.8
- Include Django middleware in better-exceptions HOT 3
- ModuleNotFoundError: No module named 'better_exceptions.integrations' HOT 3
- weird escape chars instead of lines HOT 5
- why "export BETTER_EXCEPTIONS=1" works? HOT 1
- terminfo (tmux-256color, xterm-256color) not considered to be valid HOT 6
- Don't print stack frames from certain libraries HOT 5
- How to hide sensibles data like passwords, tokens, ... HOT 1
- 0.3.3: pytest is failing HOT 3
- Installing from pip triggers a "WARNING: There was an error checking the latest version of pip." HOT 1
- f_lineno not an attribute on traceback
- Define license on pypi HOT 2
- Add environment variable support for MAX_LENGTH initialization
- How to use better-exceptions in pytest?
- Can't work in child process HOT 3
- python3.11 traceback raise StopIteration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from better-exceptions.