question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[REQUEST] Suppress Tracebacks for libraries

See original GitHub issue

How would you improve Rich?

Rich has an excellent Traceback module that improves the formatting and readability of Tracebacks ✨

However, sometimes you don’t just want nice formatting, you actually just want to remove parts of the traceback. This is most common when you are using infrastructure that you know is almost never “relevant” to the traceback itself.

It would be useful if it were possible to suppress Tracebacks for certain libraries/modules/etc, so that a traceback showed more relevant information for users (at the library author’s discretion).

Some context in this twitter thread 😃 https://twitter.com/willmcgugan/status/1439494982180737025

What problem does it solve for you?

There’s a specific use-case here that might be quite common: using rich in combination with click. If you’re using click to build your CLI, then tracebacks will dump several levels of click modules in addition to the error that is in your codebase. It would be most-useful to me if I could just say “Don’t show any of the click stuff” 😃

Did I help

If I was able to resolve your problem, consider sponsoring my work on Rich, or buy me a coffee to say thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
choldgrafcommented, Sep 24, 2021

Yahoo! Thanks for the iteration, it was fun 🙂

1reaction
willmcgugancommented, Sep 22, 2021

How about something like this:

import click
from rich import traceback

traceback.install(hide_module=[click])

Then Rich would suppress any stack frame under click.__file__ ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: eliminating stack traces into library code?
The traceback module in Python's standard library lets you emit error tracebacks in a way that accords to your liking, while an exception...
Read more >
Understanding the Python Traceback
In this step-by-step tutorial, you'll learn how to read and understand the information you can get from a Python traceback. You'll walk through...
Read more >
traceback — Print or retrieve a stack traceback — Python 3.11 ...
This module provides a standard interface to extract, format and print stack traces of Python programs. It exactly mimics the behavior of the...
Read more >
Creating Beautiful Tracebacks with Python's Exception Hooks
To achieve this we will learn how to implement and use custom Exception Hooks that will remove all the noise from tracebacks, make...
Read more >
traceback – Extract, format, and print exceptions and stack ...
The traceback module works with the call stack to produce error messages. ... with no exception: None print_exc(): Traceback (most recent call last):...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found