Skip to main content

Error Wrapper

Inheritance from the package’s classes allows you to handle errors of any level in a uniform way and automatically log error messages if desired. This is a familiar routine, a fraction of which I wanted to reduce:)

Installation

Install from PyPI with:

pip install error-wrapper

Usage

Completely abstract example:)

logger = logging.getLogger(__name__)

class DivNum(ErrorWrapper):

    def test_args_number(self, *args):
        if len(args) != 2:
            self.raise_instance_error(f'{ARG_NUM_ERROR}{len(args)}')
        return

    @run_method_if_no_errors
    def test_args_type(self, *args):
        if not isinstance(args[0], int) or not isinstance(args[1], int):
            self.raise_instance_error(ARG_TYPE_ERROR)
        return

    def div(self, *args):
        self.clear_instance_error()
        self.test_args_number(*args)
        self.test_args_type(*args)
        if self.error:
            return self.error_detail
        try:
            return args[0] / args[1]
        except Exception as e:
            self.raise_instance_exception(e)
            return self.error_detail


# Default creating params: report_prefix=None, exception_name_in_detail=False,
#                          logger=None, auto_logging=False

divnum_with_defaults = DivNum()

divnum_with_auto_logging = DivNum(auto_logging=True, logger=logger)

divnum_with_prefix_in_log_or_error_vessage = DivNum(report_prefix='DevNum instance error: ')

Metadata

Release files for error-wrapper 0.9.6

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

Built distribution (wheel)

Table of built distributions (wheels) for error-wrapper 0.9.6
File Interpreter ABI Platform Actions
error_wrapper-0.9.6-py3-none-any.whl Python 3 none any Details for error_wrapper-0.9.6-py3-none-any.whl

Release files / error_wrapper-0.9.6-py3-none-any.whl

Download URL error_wrapper-0.9.6-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18f90151b05a52d63cdf8dbcc52bb93c7017f71721406171011b74844a2ce214
BLAKE2b-256 checksum
How to use checksums
d55b27f109984f3079b31739cf264d0cab99a687f972c92cf25a150d1f33b3ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Security for error-wrapper 0.9.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.6 This release

1 release file No provenance

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