Skip to main content

Base result and exception tracking utilities for Python.

Project description

한국어 (Korean)

Runtime baseline: package version 0.1.0 (tbot223_base.__version__ == "0.1.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

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-0.1.0.tar.gz (25.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-0.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tbot223_base-0.1.0.tar.gz
  • Upload date:
  • Size: 25.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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23ca9b4d5744610d209d310fd0d7839ec706eca09c80ea4ad77c8d25db87a29d
MD5 b63f98309c7fe11044f5324dd915c10a
BLAKE2b-256 53a6ae79d366fa0c3fe44ca6ac8708615edd73d6a5a17e2fec62d02ded2879b2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: tbot223_base-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b43e09eb6dcb21ff41dd665fa06e4a4daa3c41c6c5f264c3dd75b14f2400e2e
MD5 a07787690db9a0ece3121287678ac80b
BLAKE2b-256 11c657976aea1ac0339e513ea13e9513896e24b92972f95f2588105e31a5685f

See more details on using hashes here.

Provenance

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