(Better) boto3 errors
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.32.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| boto3_errors-0.32.0.tar.gz | 308.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| boto3_errors-0.32.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 881.4 kB
Release files / boto3_errors-0.32.0.tar.gz
| Download URL | boto3_errors-0.32.0.tar.gz |
|---|---|
| Size | 308.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d884e97a0e1d6859791184210eb92c0a0737d1de1797db6fbb7f4d78cc7f7922
|
|
BLAKE2b-256 checksum How to use checksums |
01bfa729863a6df1b6f3cc7dcfc5ac3881ec06f3b908a2a3aa5e1ab8b6259d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","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.32.0-py3-none-any.whl
| Download URL | boto3_errors-0.32.0-py3-none-any.whl |
|---|---|
| Size | 572.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34574d67f3f93d5f04423a17f8990f7373787ab8f4aa05070e06081298c0d5f0
|
|
BLAKE2b-256 checksum How to use checksums |
1b28e5c86a8d62fe6a3fec22fb4081ec8c0492d6c25acdc8bc9d6ad36207bdd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","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}
|