Install & Compatibility
Where this runs
tested against v2.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.066s · 48.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 3.0s · import 0.061s · 49MB
47MB installed
● package 47MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
catch_aws_error
✓ from aws_error_utils import catch_aws_error
errors
✓ from aws_error_utils import errors
✗ from aws_error_utils.errors import NoSuchBucket
The 'errors' object is imported directly, and its attributes (e.g., `errors.NoSuchBucket`) are aliases to `catch_aws_error()` calls, not actual exception classes.
aws_error_matches
✓ from aws_error_utils import aws_error_matches
get_aws_error_info
✓ from aws_error_utils import get_aws_error_info
This quickstart demonstrates how to use `catch_aws_error` to handle specific AWS `ClientError` exceptions. It attempts to access a non-existent S3 bucket, which typically raises a `NoSuchBucket` error. It also shows the alternative `errors.NoSuchBucket` syntax, which is an alias for `catch_aws_error('NoSuchBucket')`.
import boto3
from aws_error_utils import catch_aws_error, errors
import os
from botocore.exceptions import ClientError
# Configure boto3 client with dummy credentials for local testing, or load from environment
s3_client = boto3.client(
's3',
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'test'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'test'),
aws_session_token=os.environ.get('AWS_SESSION_TOKEN'), # Optional
region_name=os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
)
non_existent_bucket = "non-existent-aws-error-utils-test-bucket-12345"
print(f"Attempting to list objects in '{non_existent_bucket}'...")
try:
s3_client.list_objects_v2(Bucket=non_existent_bucket)
except catch_aws_error("NoSuchBucket") as e:
print(f"Caught expected AWS error using catch_aws_error: Code={e.code}, Message='{e.message}'")
except ClientError as e:
print(f"Caught an unexpected ClientError: {e}")
except Exception as e:
print(f"Caught a generic exception: {e}")
print("\nDemonstrating 'errors' class for common error codes (if applicable) (alias to catch_aws_error)...")
try:
s3_client.list_objects_v2(Bucket=non_existent_bucket)
except errors.NoSuchBucket as e:
print(f"Caught expected AWS error using errors.NoSuchBucket: Code={e.code}, Message='{e.message}'")
except ClientError as e:
print(f"Caught an unexpected ClientError via ClientError: {e}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_error_utils'
The 'aws-error-utils' package is not installed in the Python environment.
fixInstall the package using pip: 'pip install aws-error-utils'.
ImportError: cannot import name 'is_s3express_bucket' from 'botocore.utils'
A version mismatch between 'boto3' and 'botocore' libraries.
fixEnsure compatible versions of 'boto3' and 'botocore' are installed by updating both: 'pip install --upgrade boto3 botocore'.
ImportError: cannot import name 'safe_join'
The 'safe_join' function has been removed or relocated in the library being imported.
fixCheck the library's documentation for the updated import path or alternative functions.
ImportError: cannot import name 'process_tweet' from 'utils'
The 'utils' module does not contain a 'process_tweet' function, possibly due to a missing or incorrect import.
fixVerify that the 'utils' module is correctly implemented and contains the 'process_tweet' function.
ImportError: cannot import name 'display'
A circular import or incorrect import statement in the code.
fixRearrange the import statements to avoid circular dependencies or import errors.
Upgrade
Version history
2.7.0latest on PyPI · released Nov 3, 2022
Audit
Dependencies
boto3requiredThe library is designed to work with exceptions raised by boto3/botocore.