Giter Club home page Giter Club logo

Comments (9)

stuaxo avatar stuaxo commented on June 8, 2024 1

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.

Qix- avatar Qix- commented on June 8, 2024 1

If this can be implemented elegantly then I'm all for it. :)

from better-exceptions.

Delgan avatar Delgan commented on June 8, 2024

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.

sentientmachine avatar sentientmachine commented on June 8, 2024

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.

Delgan avatar Delgan commented on June 8, 2024

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.

Delgan avatar Delgan commented on June 8, 2024

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.

alichtman avatar alichtman commented on June 8, 2024

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.

stuaxo avatar stuaxo commented on June 8, 2024

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.

Qix- avatar Qix- commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.