Skip to main content

Define exception handling logic via a decorator.

Project description

WrapErr

The goal of WrapErr is to avoid contaminating main logic with try-catch blocks and the exception handling logic.

Without WrapErr, you have something like this:

try:
    // do something
except Exception as e:
    // exception handling logic

With WrapErr, you would write something more like this:

def error_handler(e: Exception):
    // exception handling logic

@wrap_error(error_handler)
def foo(*args, **kwargs):
    // do something

You can reuse the same error handling logic across multiple functions and methods:

def error_handler(e: Exception):
    // exception handling logic

@wrap_error(error_handler)
def foo(*args, **kwargs):
    // do something

@wrap_error(error_handler):
def bar(*args, **kwargs):
    // do something else

You can also only handle exceptions of a specific type:

def value_error_handler(e: ValueError):
    // exception handling logic

@wrap_error(error_handler, ValueError)
def foo(*args, **kwargs):
    // do something

And you can combine different error handlers that handle different exceptions:

def value_error_handler(e: ValueError):
    // exception handling logic

def attribute_error_handler(e: AttributeError):
    // more exception handling logic

@wrap_error(value_error_handler, ValueError)
@wrap_error(attribute_error_handler, AttributeError)
def foo(*args, **kwargs):
    // do something

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

wraperr-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wraperr-1.0.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file wraperr-1.0.2.tar.gz.

File metadata

  • Download URL: wraperr-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for wraperr-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cc162e55bc080dd789841929923ffc365976d549ea5c3504d88bd9d4ee94107a
MD5 d5be18937559abf51302e780d9754eea
BLAKE2b-256 22dcce637d0f00ef16923a55595079891753a68e97471942afb0fb0ea2122c85

See more details on using hashes here.

File details

Details for the file wraperr-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: wraperr-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for wraperr-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 814fc876111effeb67f018005ca8d20ace886bee22295b90c9012a7a7885a082
MD5 78f2d60070578f7c93de809524001bcf
BLAKE2b-256 9118cc82623495b04ed93b9ac3ba23de5242c98b3565d11c2698781711e12594

See more details on using hashes here.

Supported by

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