Skip to main content

neterr

Groupings of exceptions for working with network requests.

When making network requests in python there are a number of possible exceptions to due network issues. These are often a temporarily problem that should be prioritized separately from a bug in code. As a result handling them with a bare except is not safe but knowing exactly what exceptions to handle can be difficult.

Installation

pip install neterr

Error Groups

neterr provides the exception groups SocketErrors, StrictHTTPErrors, AmbiguousHTTPErrors and HTTPErrors.

Usage Example

import urllib.request
from neterr import HTTPErrors
try:
    urllib.request.urlopen('http://127.0.0.1').read()
except HTTPErrors:
    print('caught!')

SocketErrors

SocketErrors contains exceptions that may be raised while working with the socket module.

StrictHTTPErrors

StrictHTTPErrors contains exceptions that may be raised while working with the http module and some common modules that use it (such as urllib and requests). This grouping only contains exceptions that are clearly not the result of code. They may be caused by an infrastructure or configuration problem and are often temporary.

StrictHTTPErrors is a superset of SocketErrors.

AmbiguousHTTPErrors

AmbiguousHTTPErrors contains exceptions that may be raised while working with the http module and some common modules that use it (such as urllib and requests). This grouping contains exceptions that may or may not be caused by code. The most common reason for this ambiguity is that they are the result of an HTTP response with a 4xx or 5xx status. It is recommended to handle 4xx and 5xx responses separately. 4xx responses are often caused by unvalidated user input or another code issue. 5xx responses are often caused by temporarily unavailability in a dependent service.

HTTPErrors

StrictHTTPErrors contains exceptions that may be raised while working with the http module and some common modules that use it (such as urllib and requests).

HTTPErrors is a superset of StrictHTTPErrors and AmbiguousHTTPErrors.

Combining Errors

Exception groups provided by neterr can be combined with other exceptions using the add operator.

from neterr import HTTPErrors

try:
    raise MyException()
except HTTPErrors + MyException:
    print('caught!')

try:
    raise MyException()
except HTTPErrors + (MyException, MyOtherException):
    print('caught!')

try:
    raise MyException()
except HTTPErrors + [MyException, MyOtherException]:
    print('caught!')

Versioning

This package strictly follows semantic versioning.

Metadata

Release files for neterr 1.1.1

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

Source distribution (sdist)

Source distribution for neterr 1.1.1
File Size Uploaded
neterr-1.1.1.tar.gz 9.6 kB Details

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / neterr-1.1.1.tar.gz

Download URL neterr-1.1.1.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c948e5a51a53028d2651daa9e95dc2a43c26773640bae7bafe6cad6f9dc559bb
BLAKE2b-256 checksum
How to use checksums
ec7fca130326628544ef55148d05d3962824e2bb9f698544644447d04d055801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

Release files / neterr-1.1.1-py3-none-any.whl

Download URL neterr-1.1.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df75f54413203e03a78b4255f04154c6da19b8c1a060c5275095fa9864efce03
BLAKE2b-256 checksum
How to use checksums
fc0fae3086c9d5b7235bff7208316e3e18155c2bf2f0d049dba9007fe1f218e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

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