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.1.tar.gz (4.9 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.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wraperr-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 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.1.tar.gz
Algorithm Hash digest
SHA256 82b77051f24228970d7c7fbd46d4140bcc60723ed7f0f89b3b56a056e973a82b
MD5 1ca971d875b027b497ea7808ece72b9b
BLAKE2b-256 cd008fd5ae39a75245d084e0b8f4ef9e9e341279a2c96b5d67c154b7779d3574

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wraperr-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a71d0f6477e5cf5a24be1ae4d504236b2f6317fc9da8222495e0d3738935b3c1
MD5 d7feb91d4311021c4f9d0577ae517f76
BLAKE2b-256 2d1977ba66ca1bc813c638c8c4492649085d145e8d72b2fb41324d7e4f3219c9

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