Three-audience error framework: typed errors for code, actionable suggestions for humans, tool guidance for AI agents
Project description
actionable-errors
Three-audience error framework for Python.
Every ActionableError speaks to three audiences simultaneously:
| Audience | Uses | Provided by |
|---|---|---|
| Calling code | Typed ErrorType for routing (retry? escalate? ignore?) |
ErrorType(StrEnum) — 8 base categories |
| Human operator | suggestion + Troubleshooting steps |
Frozen dataclasses with actionable text |
| AI agent | AIGuidance with concrete next tool calls |
Frozen dataclass with tool suggestions |
Install
pip install actionable-errors
Zero runtime dependencies — stdlib only. Sits at the bottom of every dependency tree.
Quick Start
from actionable_errors import (
ActionableError,
AIGuidance,
ToolResult,
from_exception,
sanitize,
)
# Domain-specific factory with built-in defaults
error = ActionableError.authentication(
service="Azure DevOps",
raw_error="401 Unauthorized",
)
print(error.suggestion) # "Check your credentials and try again."
print(error.ai_guidance) # AIGuidance(action_required="Re-authenticate", command="az login")
# Auto-classify any exception
try:
raise ConnectionError("Connection refused")
except Exception as exc:
ae = from_exception(exc, service="Kusto", operation="query")
print(ae.error_type) # "connection"
# Typed result envelope for MCP tool responses
result = ToolResult.ok(data={"items": 42})
result = ToolResult.fail(error=error) # extracts error_type + suggestion
# Credential sanitization
clean = sanitize('password="hunter2" token=abc123')
# → 'password="***" token=***'
Extending ErrorType
Python StrEnum can't be subclassed once it has members, so extend via composition:
from enum import StrEnum
from actionable_errors import ActionableError
class RAGErrorType(StrEnum):
EMBEDDING = "embedding"
INDEX = "index"
error = ActionableError(
error="Vector store unavailable",
error_type=RAGErrorType.INDEX,
service="pinecone",
suggestion="Check Pinecone cluster status.",
)
Factories
Eight domain-specific factories with sensible defaults:
| Factory | Key Parameters |
|---|---|
.authentication(service, raw_error) |
Default suggestion + AI guidance |
.configuration(field_name, reason) |
— |
.connection(service, url, raw_error) |
— |
.timeout(service, operation, timeout_seconds) |
— |
.permission(service, resource, raw_error) |
— |
.validation(service, field_name, reason) |
— |
.not_found(service, resource_type, resource_id, raw_error) |
— |
.internal(service, operation, raw_error) |
— |
All factories accept optional suggestion, ai_guidance, and troubleshooting kwargs.
Development
# Install dev dependencies
uv sync --extra dev
# Run all checks
task check # lint → type → test (90 tests, 100% coverage)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file actionable_errors-0.1.1.tar.gz.
File metadata
- Download URL: actionable_errors-0.1.1.tar.gz
- Upload date:
- Size: 68.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd102184f10658e5041e92046e6f544782342cce48ba7a0db8195ef6303e4318
|
|
| MD5 |
1e0b3270f052b853eb1373ae81fd77dd
|
|
| BLAKE2b-256 |
4551a370e9437ebfa79cb9f521614ed2bf3debd97a0c3d1c34879cb9a1b0afcb
|
Provenance
The following attestation bundles were made for actionable_errors-0.1.1.tar.gz:
Publisher:
publish.yml on grimlor/actionable-errors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
actionable_errors-0.1.1.tar.gz -
Subject digest:
bd102184f10658e5041e92046e6f544782342cce48ba7a0db8195ef6303e4318 - Sigstore transparency entry: 1018836584
- Sigstore integration time:
-
Permalink:
grimlor/actionable-errors@d15f85f935d8bf8fb9e01a77a86a1dcfbd6a230f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/grimlor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d15f85f935d8bf8fb9e01a77a86a1dcfbd6a230f -
Trigger Event:
release
-
Statement type:
File details
Details for the file actionable_errors-0.1.1-py3-none-any.whl.
File metadata
- Download URL: actionable_errors-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
185e1e5c24c0264f4f02ccf855a8d55ea999882b9884f06f34c8c1cc34202774
|
|
| MD5 |
a77f468d4d748408d846373536019611
|
|
| BLAKE2b-256 |
7b31c56059b7c9327e16731756d113ce7346ad8e617e115f555cec5c2213a884
|
Provenance
The following attestation bundles were made for actionable_errors-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on grimlor/actionable-errors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
actionable_errors-0.1.1-py3-none-any.whl -
Subject digest:
185e1e5c24c0264f4f02ccf855a8d55ea999882b9884f06f34c8c1cc34202774 - Sigstore transparency entry: 1018836627
- Sigstore integration time:
-
Permalink:
grimlor/actionable-errors@d15f85f935d8bf8fb9e01a77a86a1dcfbd6a230f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/grimlor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d15f85f935d8bf8fb9e01a77a86a1dcfbd6a230f -
Trigger Event:
release
-
Statement type: