Skip to main content

Base result and exception tracking utilities for Python.

Project description

한국어 (Korean)

Runtime baseline: package version 1.0.0rc1 (tbot223_base.__version__ == "1.0.0rc1").

tbot223-base

tbot223-base is a small Python base package for exchanging operation results and safe exception payloads across function and module boundaries.

It provides two core pieces:

  • Result and ResultStatus for explicit success, failure, and cancelled outcomes.
  • ExceptionTracker for separating internal debug diagnostics from public-safe error payloads.

Design Intent

tbot223-base was shaped by Python boundary-handling needs, not by an attempt to reproduce another language's API.

Rust's Result can be a useful comparison point for readers, but it is not the source model or compatibility target for this package. Here, Result is a Python-style exchange protocol: a small value shape that lets functions pass status, data, context, and error text without guessing how the caller wants to handle the outcome.

ExceptionTracker exists for safe error handling at boundaries. It does not make errors disappear; it keeps rich internal diagnostics available while producing a smaller public payload that avoids traceback, local variable, system, or raw exception leakage.

Who This Is For

This package fits codebases that want:

  • a stable result shape for function, service, worker, or module boundaries.
  • a lightweight way to return success, failure, and cancellation without inventing a new dictionary shape in each layer.
  • public-safe error payloads for APIs, UI surfaces, bot responses, or other untrusted boundaries.
  • debug diagnostics that can stay richer than public responses.
  • a small typed utility package rather than a framework.

It is especially useful when an operation result is part of the interface between components, not just a local implementation detail.

Trade-offs

Result makes outcomes explicit, but that also means callers and callees must agree to pass and inspect a structured value. For very small scripts or code where normal exceptions are already the clearest control flow, this can be unnecessary ceremony.

ExceptionTracker intentionally separates public and debug payloads. That is safer for public boundaries, but it also means public responses will not contain raw exception messages, traceback frames, local variables, or system information unless you explicitly provide safe public text.

This package is not:

  • a Rust-compatible Result implementation.
  • a pattern-matching or monadic result framework.
  • a logging, tracing, metrics, or observability system.
  • a replacement for Python exceptions inside purely local control flow.

Installation

python -m pip install tbot223-base

For local development from a source checkout:

python -m pip install -e ".[test]"

Quickstart

Create and inspect a result.

from tbot223_base.result import Result, ResultStatus

result: Result[dict[str, int]] = Result(
    status=ResultStatus.SUCCESS,
    error=None,
    context="FetchProfile",
    data={"user_id": 1},
)

if result.is_success:
    print(result.unwrap())

Return a public-safe exception payload.

from tbot223_base.exception_tracker import ExceptionTracker

tracker = ExceptionTracker()

try:
    1 / 0
except Exception as error:
    result = tracker.get_public_exception_return(
        error,
        error_code="DIVIDE_BY_ZERO",
        public_message="The calculation could not be completed.",
        public_context="Calculator.Divide",
        retryable=False,
    )
    print(result.data)

Documentation

User-facing docs:

Repository maintenance docs:

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

tbot223_base-1.0.0rc1.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

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

tbot223_base-1.0.0rc1-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file tbot223_base-1.0.0rc1.tar.gz.

File metadata

  • Download URL: tbot223_base-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tbot223_base-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 8f6478d2e3bb978c4467fbf7275f283ef8e647eac4f44958688f397b42a00699
MD5 908eb6fb9c2381ea02ff5bc64caa3c0a
BLAKE2b-256 a68bded0404eb361b4851937c8d29287eea0a542f4d6eca811823904cf26b43d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0rc1.tar.gz:

Publisher: publish.yml on Tbot223/tbot223-base

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tbot223_base-1.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: tbot223_base-1.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tbot223_base-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e107b3e53b2549ef20c76e20f34e4e58f16127a14e733b054e5676ed7b2232f
MD5 acaab98122d65c125e54c1a0c5d78400
BLAKE2b-256 0e42eb609559d8e034c70fff5d88b7f6c48968ddb7e3d0f41a8f900b56470a47

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0rc1-py3-none-any.whl:

Publisher: publish.yml on Tbot223/tbot223-base

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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