Skip to main content

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

Metadata

Release files for noraise 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noraise 0.0.16
File Size Uploaded
noraise-0.0.16.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for noraise 0.0.16
File Interpreter ABI Platform
noraise-0.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / noraise-0.0.16.tar.gz

Download URL noraise-0.0.16.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7bbcdddd70ffdd61ee7a17cf072e6e03930c5b04894c593c85d113df1a6925c9
BLAKE2b-256 checksum
How to use checksums
6d39855fc64b1f5b8851c5eae9aa95c077263dedd3aea9127f64e908e8080011
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / noraise-0.0.16-py3-none-any.whl

Download URL noraise-0.0.16-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d768f8844758138817cdd4731e1eb6b843caef9bc926fea44267617811ebcced
BLAKE2b-256 checksum
How to use checksums
a8b818213fb658b780c36594479d985db5936d6294e14f8d0cb1fc0514362340
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page