Skip to content

Comment on Stack Traces Are Underrated

Comments

Stack traces are very valuable. Sometimes it can even help to attach them to some object creation, when you later wonder why/how/where this object was created. E.g. in TensorFlow, every single Tensor had a traceback attached to it, so when there was any error later on, it would show you where it was created. This is maybe less needed now with eager mode, but you might have other similar situations.

One problem with stack traces is maybe that they can be too verbose. E.g. if you print them for any warning you print to log (or stdout). Sometimes they will be extremely helpful for debugging some problem, but in many cases, you maybe don't need them (you know why you get the warning and/or you don't care about it).

You could also add more information to the stack trace such as local variables. That can be even more helpful for debugging then, but again adds more verbosity.

For example, we often use this to add information about relevant local variables: https://github.com/albertz/py_better_exchook

One solution to the problem with verbosity is when you have foldable text output. Then the stack trace is folded away (not shown in all details) and you can unfold it to see the details. See the DomTerm demo here: https://github.com/albertz/py_better_exchook#domterm

Some more on text folding:

https://github.com/PerBothner/DomTerm/issues/54

https://gitlab.com/gnachman/iterm2/-/issues/4950

https://github.com/xtermjs/xterm.js/issues/1875

https://gitlab.freedesktop.org/terminal-wg/specifications/-/...

https://github.com/vercel/hyper/issues/1093

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.