Skip to main content

EZCeption (and EZMessage)

These classes provide a simplified means to define exception classes and message attributes.

Goals

  • Less boilerplate to define error classes so they'll be used more.
  • Formatting does not happen at raise time so catching errors doesn't incur string computation cost.
  • Exception fields are easier to probe by exception handlers.
  • Class-bases exceptions are a snap to define.
  • Works with regular Python exception classes.
  • Interfaces with the gettext module by default.
  • Allows for associating other i18n messaging in the error classes.

Installation.

pip install ezception

NOTE: ezception is not on pypi yet. Until official releases are available:

pip install https://github.com/hrharkins/ezception/archive/master.zip

Usage

import ezception

class MyWebRequester(object):

    class Error(ezception.EZCeption):
        'A general error has occurred.'

    class OpenError(Error):
        'An error opening {self.url!r} has occurred.'

    class NoURLError(OpenError):
        '''
        No URL was provided.
        ''''

    class NoURLError(OpenError):
        '''
        The scheme {self.scheme!r} is not acceptable.
        '''

    ...

    def open(self, url):
        ... stuff happens.

        ... Oh noes!
        raise self.BadSchemeError(scheme=url.scheme)

So in the example the class defines a simple hierarchy of errors. Progreammers can trivially trap MyWebRequester.Error to catch anything generated by MyWebRequester. Because it's very simple to define those errors, a more robust exception hierarchy is more likely to emerge.

In addition, the message is NOT generated at exception time. Because of this, it is easy to catch and determine better handling code. The default Python exceptions use args, which requires the programmer to have tighter coupling with the error classes to acquire the parameters of the failure (or the error class needs to define more properties).

Only when the exception is printed does stringification occur. In addition, the message to be presented is processed using the gettext module, so adding support for other languages for such messages is possible using regular .po files. All messages are tracked by a global ezception.ALL_MSGS dict so generating base .po files is also simplified.

Metadata

Release files for ezception 0.0.2

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

Source distribution (sdist)

Source distribution for ezception 0.0.2
File Size Uploaded Provenance Actions
ezception-0.0.2.tar.gz 3.4 kB Without provenance Details for ezception-0.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 19.1 kB

Release files / ezception-0.0.2.tar.gz

Download URL ezception-0.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
de646cf765f5917dbcff56e3770a9b7562c005c61951aed3f53d693118740e22
BLAKE2b-256 checksum
How to use checksums
23a100276ddd21eca672e469c883e6151a7dc62d214b7bccdf5456e54a679293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

Release files / ezception-0.0.2-py3-none-any.whl

Download URL ezception-0.0.2-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e02d48cd29d2c76ad636663618e9c44af1b5788554f1c9306c280b9f50262a7
BLAKE2b-256 checksum
How to use checksums
bb0070ce0cc433c5e2ad5e7e5351c78d18409170d29b6f3cf3a5b143440fe8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

Security for ezception 0.0.2

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.0.2 This release

2 release files 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