Skip to main content

Structured exception handling and error classification for Python

Project description

Error Framework

Purpose

VCollab Python scripts are typically invoked by partner programs or external applications. When a script finishes, the invoking application needs to know what happened — did it succeed, fail due to a missing file, a license issue, or something unexpected?

In standard subprocess semantics, the exit code is the only reliable contract between caller and callee. The vcti-error package formalizes this contract by ensuring that every known exception type maps to a stable, unique integer exit code — consistent across all VCollab applications.

This package has zero external dependencies.

When to use this package

Use vcti-error when your Python script is invoked as a subprocess by a partner application (e.g., VCollab Presenter, an external scheduler, or a CI pipeline) and the caller interprets the process exit code to decide what happened. If your code runs inside a larger Python process where exceptions propagate normally, you likely don't need this package.


Installation

pip install vcti-error

In requirements.txt

vcti-error>=1.0.5

In pyproject.toml dependencies

dependencies = [
    "vcti-error>=1.0.5",
]

Quick Start

The main() pattern

All CLI entry points follow this structure:

import logging
import traceback
from vcti.error import error_code

logger = logging.getLogger(__name__)

def main() -> int:
    try:
        cli_app()
        return 0
    except Exception as error:
        logger.error("Error: %s", error)
        traceback.print_exc()
        return error_code(type(error))
  • 0 — success
  • != 0 — failure (category encoded in exit code)
  • error_code(type(error)) — resolves exception class to exit code
  • Unmapped exceptions fall back to UNSPECIFIED (exit code 1)

Look up exit codes

from vcti.error import error_code

error_code(FileNotFoundError)   # 2
error_code(KeyError)            # 4
error_code(RuntimeError)        # 1 (UNSPECIFIED fallback)

Resolve exception class by name

from vcti.error import exception_class

exception_class("file_not_found")       # FileNotFoundError
exception_class("variable_undefined")   # VariableUndefined
exception_class("unknown_name")         # Exception (fallback)

Create system errors with errno

from vcti.error import system_error

err = system_error(FileNotFoundError, "path/to/file")
# FileNotFoundError(errno.ENOENT, "No such file or directory", "path/to/file")
raise err

Registered Exception Types

Exception type Exit code Python class Description
UNSPECIFIED 1 Exception Fallback for unmapped exceptions
FILE_NOT_FOUND 2 FileNotFoundError Expected file not found
LICENSE_ERROR 3 LicenseError License validation failed
KEY_ERROR 4 KeyError Missing key or identifier
VARIABLE_UNDEFINED 5 VariableUndefined Undefined workflow variable

Stability guarantee: Exit code values are part of the external contract with partner applications. Once assigned, a value must never be changed or reused.


Public API

Function Purpose
error_code(exception_class) Returns exit code for an exception class
exception_class(name) Resolves exception type name to Python class (case-insensitive)
system_error(exception_class, *args) Creates exception with appropriate errno

Documentation

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

vcti_error-1.0.5.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

vcti_error-1.0.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file vcti_error-1.0.5.tar.gz.

File metadata

  • Download URL: vcti_error-1.0.5.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vcti_error-1.0.5.tar.gz
Algorithm Hash digest
SHA256 9db254819825d0209c0e13357beaad85339b606f1ce1232b8bd04b692159e297
MD5 1899dc3df0fb312b7d5e5e4ef2f8886d
BLAKE2b-256 e62705415fb4816d435b7cec942d6f9ec8f523c9b789e2777a1aa2a0737d0062

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_error-1.0.5.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-error

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

File details

Details for the file vcti_error-1.0.5-py3-none-any.whl.

File metadata

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

File hashes

Hashes for vcti_error-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 da2881da5d14bb0d816555fefe45ba1c58f1b4e4759987f42a2382dd7bf90b63
MD5 3d7db266eb09ff606ade8feb9a761846
BLAKE2b-256 2054208c9f06dc946da3b100f8e5638eb0caab1983ee706ca32ad3fc3c4a197d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_error-1.0.5-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-error

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