Skip to main content

Base result and exception tracking utilities for Python.

Project description

한국어 (Korean)

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

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==1.0.0"

For the latest stable release without pinning a version, use python -m pip install tbot223-base.

For local development from a source checkout:

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

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.0.tar.gz (92.0 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.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tbot223_base-1.0.0.tar.gz
  • Upload date:
  • Size: 92.0 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.0.tar.gz
Algorithm Hash digest
SHA256 a948e4b70695dcb74df2c1f4b37d966aab1e2a179c1ef90a07e1b1294556143d
MD5 b65466bd6a40930b1916924338cd8d90
BLAKE2b-256 c43e99afb7d1d03102f5c0ab81c8052aac1ab5f04d19a28a36971931d7d548eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: tbot223_base-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51e0e6772d8b7dde6a1f27db8d9f6f4da7e9b396a133e024359545540b5784d8
MD5 b130c7c52afb7e7efa1f547ce0f32c98
BLAKE2b-256 ff891fcf422ec12b4c63916f3c6271914dfa560c5ee8fbdf862f9f3ef43b9e91

See more details on using hashes here.

Provenance

The following attestation bundles were made for tbot223_base-1.0.0-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