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 details)

Uploaded Source

Built Distribution

noraise-0.0.16-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file noraise-0.0.16.tar.gz.

File metadata

  • Download URL: noraise-0.0.16.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for noraise-0.0.16.tar.gz
Algorithm Hash digest
SHA256 7bbcdddd70ffdd61ee7a17cf072e6e03930c5b04894c593c85d113df1a6925c9
MD5 ada48609fa38140aeffbcb4c5cc5cfd8
BLAKE2b-256 6d39855fc64b1f5b8851c5eae9aa95c077263dedd3aea9127f64e908e8080011

See more details on using hashes here.

File details

Details for the file noraise-0.0.16-py3-none-any.whl.

File metadata

  • Download URL: noraise-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for noraise-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 d768f8844758138817cdd4731e1eb6b843caef9bc926fea44267617811ebcced
MD5 133d1e6f4270cab76933dc6a1dd96429
BLAKE2b-256 a8b818213fb658b780c36594479d985db5936d6294e14f8d0cb1fc0514362340

See more details on using hashes here.

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