Skip to main content

noraise

Project description

noraise

PyPI - package version PyPI - license PyPI - python version PyPI - downloads

GitHub - last commit GitHub - commit activity

GitHub - code size in bytes GitHub - repo size GitHub - lines of code

GitHub - license

Description

Lightweight utility package, that provides a function decorator to easily catch and print exceptions

Supported Args

name type default value description
print_exc bool True If True, prints stacktrace
return_exception bool False If True, returns caught exception
default_return_value Optional[any] None What to return upon caught exception if
'return_exception' is False
ignored_error_types Optional[List[Exception]] None In which cases should the stacktrace print
be skipped if 'print_exc' is True

Install

pip install noraise
# or
pip3 install noraise

Usage

from noraise import noraise

@noraise(print_exc=True, return_exception=True, ignored_error_types=[ZeroDivisionError])
def f2():
    return 1/0

res = f2()
print(type(res), res)

# This will not catch the crash, and print
# 
# 
# < ------------------------------------- Caught with @noraise ------------------------------------ >
#
# Traceback (most recent call last):
#   File "/Users/kristofk/github/py_noraise/noraise/noraise.py", line 32, in wrapper
#     return function(*args, **kwargs)
#   File "demo.py", line 5, in f2
#     return 1/0
# ZeroDivisionError: division by zero
# 
# < ----------------------------------------------------------------------------------------------- >
# 
# 
# <class 'ZeroDivisionError'> division by zero

Dependencies

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

noraise-0.0.16.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

noraise-0.0.16-py3-none-any.whl (4.2 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