Skip to main content

STFU those exceptions (explicitly)

Project description

Silence chosen exceptions.

Author: João Bernardo Oliveira - @jbvsmo

Replacement for the idiom:

>>> try:
...     may_raise_exception()
... except Exception:
...     pass

Just write:

>>> with stfu:
...     may_raise_exception()
>>> with stfu(TypeError, ValueError):
...     may_raise_exception()

To catch everything (even KeyboardInterrup and StopIteration):

>>> with stfu_all:
...     may_raise_any_exception()
“Errors should never pass silently.

Unless explicitly silenced.” :)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions (1.9 kB view hashes)

Uploaded source

stfu-1.2.tar.gz (1.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page