Skip to main content

PyError

PyError banner

A robust error handling and exception management library for Python. PyError provides utilities for logging and raising exceptions with flexible exception types, error codes, and custom parameters.

Features

  • Flexible Exception Handling: Support for custom exceptions with configurable error codes and additional parameters.
  • Logging Integration: Integrated logging via flashlogger for fatal, critical, and error levels.
  • Positional and Keyword Arguments: Support for passing additional arguments (*args) and keyword arguments (**kwargs) to exceptions.
  • Multiple Exception Types: Functions for fatal, critical, and error scenarios with consistent interfaces.
  • Easy Extension: Extensible design allowing custom exception classes with complex initialization logic.

Installation

Install from PyPI:

pip install PyError

Or clone the repository and install locally:

git clone https://github.com/kingkybel/PyError.git
cd PyError
pip install .

Usage

Fatal Errors

from error import fatal

# Raise a fatal error with default SystemExit
fatal("Critical system failure")

# Raise a fatal error with custom error code
fatal("Database connection failed", error_code=2)

# Raise a custom exception
class DatabaseError(Exception):
    def __init__(self, code, *args, **kwargs):
        self.code = code
        super().__init__(*args, **kwargs)

fatal("Connection timeout", exception=DatabaseError, error_code=42)

Critical Errors

from error import critical

# Raise a critical error
critical("Authentication failed")

# With custom exception
critical("Invalid configuration", exception=ConfigError, error_code=10)

Standard Errors

from error import error

# Raise an error
error("File not found")

# With additional parameters
error("Operation failed", exception=OperationError, error_code=1)

Advanced Usage

Custom Exceptions with Extra Parameters

from error import fatal

class AppError(Exception):
    def __init__(self, code, *args, **kwargs):
        self.code = code
        self.context = kwargs.get('context')
        self.timestamp = kwargs.get('timestamp')

# Pass extra keyword arguments
fatal("App failed", AppError, 5, context="user_login", timestamp="2026-05-04")

Testing

Run the test suite:

python -m unittest PyError.test.test_error

Or with verbose output:

python -m unittest PyError.test.test_error -v

Requirements

  • kingkybel-pyfundamentals
  • kingkybel-pyflashlogger

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Metadata

Release files for kingkybel-pyerror 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kingkybel-pyerror 0.1.1
File Size Uploaded Provenance Actions
kingkybel_pyerror-0.1.1.tar.gz 3.4 kB Without provenance Details for kingkybel_pyerror-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kingkybel-pyerror 0.1.1
File Interpreter ABI Platform Actions
kingkybel_pyerror-0.1.1-py3-none-any.whl Python 3 none any Details for kingkybel_pyerror-0.1.1-py3-none-any.whl

Total release size: 6.4 kB

Release files / kingkybel_pyerror-0.1.1.tar.gz

Download URL kingkybel_pyerror-0.1.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d7cfecfe865e249d618baecf142cadb4ff5a6a49b6f8503084ee069a9b660231
BLAKE2b-256 checksum
How to use checksums
d85dfa13cdf53c8ed02d80215de1caafed3e840826ed5e9ba0adc1a505900158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / kingkybel_pyerror-0.1.1-py3-none-any.whl

Download URL kingkybel_pyerror-0.1.1-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d1b69e8d4431385aa4242efa0c9d0ba84701d95b99061a4087fb5350ef70bfd
BLAKE2b-256 checksum
How to use checksums
bc0762fc169dd05e4d034b458c9ed212919e6a113e0babd12554d17afc0d1048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for kingkybel-pyerror 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page