Skip to main content

Typed, statically-importable exception classes for every AWS service

Project description

(Better) boto3 errors

Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14 PyPI License: MIT

Typed, statically-importable exception classes for every AWS service.

Install

pip install boto3-errors

Quick start

import boto3
from boto3_errors import patch_client
from boto3_errors.dynamodb import ConditionalCheckFailedException

client = boto3.client("dynamodb")
patch_client(client)

try:
    client.put_item(
        TableName="users",
        Item={"pk": {"S": "user#1"}, "name": {"S": "Ada"}},
        ConditionExpression="attribute_not_exists(pk)",
    )
except ConditionalCheckFailedException as e:
    print(e.message)  # "The conditional request failed"
    print(e.error_code)  # "ConditionalCheckFailedException"
    print(e.item)  # {"pk": {"S": "user#1"}, "name": {"S": "Ada"}}

The problem

Every boto3 error comes back as a ClientError. The only way to distinguish them is by parsing e.response["Error"]["Code"] — a stringly-typed dict lookup with no autocomplete, no type checking, and no IDE support. A typo in the error code string won't be caught until it crashes.

What you get

All AWS services with exception classes auto-generated from botocore's service model.

Exception hierarchy

ClientError                     # botocore base — still works
└── Boto3Error                  # boto3-errors base
    └── DynamoDBError           # per-service base
        ├── ConditionalCheckFailedException
        ├── ResourceNotFoundException
        ├── TransactionCanceledException
        └── ...

Every exception is a ClientError subclass, so existing except ClientError handlers keep working.

Built-in properties

Every Boto3Error exposes:

Property Type Source
message str Error.Message
error_code str Error.Code
http_status_code int ResponseMetadata.HTTPStatusCode
request_id str ResponseMetadata.RequestId

Service-specific properties

Some exceptions expose extra fields from the API response:

from boto3_errors.dynamodb import (
    ConditionalCheckFailedException,
    TransactionCanceledException,
)

# ConditionalCheckFailedException.item -> dict | None
# TransactionCanceledException.cancellation_reasons -> list | None

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

boto3_errors-0.7.0.tar.gz (299.2 kB view details)

Uploaded Source

Built Distribution

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

boto3_errors-0.7.0-py3-none-any.whl (552.1 kB view details)

Uploaded Python 3

File details

Details for the file boto3_errors-0.7.0.tar.gz.

File metadata

  • Download URL: boto3_errors-0.7.0.tar.gz
  • Upload date:
  • Size: 299.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for boto3_errors-0.7.0.tar.gz
Algorithm Hash digest
SHA256 977fcf35f2dd60eacb5607934d3e087a7251688f8cb01f579dd64f1ae011da1b
MD5 97fbbf932dabbaa57a4e4e8b52a58a37
BLAKE2b-256 7dbef62e2e70cde96a69d9e769a2eaad28f9c122f7144cead63d0f3f797d36a8

See more details on using hashes here.

File details

Details for the file boto3_errors-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: boto3_errors-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 552.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for boto3_errors-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 661b9e8edc96152b39f0717a0e30beca8b1e8174ad7cc1a4407541c596c6ef08
MD5 4f272b33bfa37024ae2189997c42a6b7
BLAKE2b-256 269e84808c9c93957f55c551a3fb4696e422cd2e7346515e8a2fb766d94cd0b5

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