by o11c · 2y ago · 0 comments
That said:
* Would printing the trace as a tree actually clarify anything?
* Good code almost always minimizes the amount of code in an exception handler.
* `raise_exception()` is generally bad practice; consider `raise get_exception()` if you need something complicated (among others, this allows choice of `from`)
* `raise ... from None` is useful since it's often the most recent stacktrace that's actually relevant.
* `raise ... from e` likely implies that it is the older stacktrace that's most relevant; ideally this would just be a single annotation on a particular frame "exception was replaced here".
python is the only one doing this weird crap
`raise_exception()` in the example is just to ensure a trivial example which still has a stacktrace in the handler (this is not uncommon in reality, though in reality the called function is not typically called with the goal of triggering yet another example)
Could you give an example of what this tree would look like? A stack is entirely linear.
I've never had a problem with Python's stack traces. Certainly better than Java, where the paradigms rely on a ridiculous amount of introspection, reflection, and abstraction, so your stack traces end up being a hundred lines long, with half of them being ".invoke()".