Skip to main content

Catch all exceptions and return None

Project description

Safe

This is quite a simple package. It catches all exceptions within a given callable and returns None, if they occur and the return-value of the callable if not.

def boom():
    raise Exception()
    return 1

def non_boom():
    return 2

a = safe(lambda: boom())
b = safe(lambda: non_boom())

assert a == None
assert b == 2

Project details


Download files

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

Source Distribution

exception_safe-0.0.3.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

exception_safe-0.0.3-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

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