Skip to main content

(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

Release files for boto3-errors 0.23.0

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

Source distribution (sdist)

Source distribution for boto3-errors 0.23.0
File Size Uploaded
boto3_errors-0.23.0.tar.gz 306.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for boto3-errors 0.23.0
File Interpreter ABI Platform
boto3_errors-0.23.0-py3-none-any.whl Python 3 none any Details

Total release size: 874.4 kB

Release files / boto3_errors-0.23.0.tar.gz

Download URL boto3_errors-0.23.0.tar.gz
Size 306.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a9a2dcb4555621850efb716a189a38c8008eeda484fab1bb8e154eaa460c97ac
BLAKE2b-256 checksum
How to use checksums
8ecbe8cc22805b97b9d3f5b20af1d08ba8cc4cd739a0a81ac7715d548988ca2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}

Release files / boto3_errors-0.23.0-py3-none-any.whl

Download URL boto3_errors-0.23.0-py3-none-any.whl
Size 567.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a3afa1f080d928672e3fa4c465bd7f5c8eb239733ec610ef3ac00c809e7bdd8
BLAKE2b-256 checksum
How to use checksums
8d050f25a89565a4bbce4ca68ee16f5b15113d56646b8c988137ece5c922487f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}

Release history Release notifications | RSS feed

0.41.0

2 release files

0.40.0

2 release files

0.36.0

2 release files

0.35.0

2 release files

0.34.0

2 release files

0.33.0

2 release files

0.32.0

2 release files

0.31.0

2 release files

0.30.0

2 release files

0.29.0

2 release files

0.26.0

2 release files

0.25.0

2 release files

0.24.0

2 release files

This release

0.23.0 This release

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.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