Skip to main content

An awesome library for 40+ additional useful Python exceptions

Project description

🌶️ tastyerrors: The Exception Library That Just Gets It

PyPI Version License Maintenance

🤯 Why Use tastyerrors?

Look, we've all been there. You're writing code, things break, and Python throws a generic Exception. You stare at the traceback and think, "What am I, a detective?"

tastyerrors is here to stop the madness. We don't just raise exceptions; we give them names, docstrings, and a dedicated place in the hierarchy so you know exactly why your user's password was too short, or why their database connection is on the fritz. We believe every error message should be a small, dramatic novella.

Plus, we’ve made sure our foundation is solid. All of our code, including the whopping 43+ exceptions, is released under the Apache License, Version 2.0. This means you can use, modify, and distribute this library freely, even in commercial applications, as long as you provide proper attribution and adhere to the license terms. Go forth and fail elegantly!


🍴 Installation

pip install tastyerrors

👩‍🍳 Quick Usage: The Two Tastiest Ways To Fail

Thanks to our beautiful, new architecture, you can handle errors with surgical precision or raise them dynamically using their string names.

  • 1: Catch 'em all!

Example

from tastyerrors import * # Wildcard is approved for quick use!

def check_user_input(username, password):
    if len(password) < 8:
        # A specific error with a clear name
        raise PasswordTooShort("Password requires at least 8 characters, please.")
    if username in ["admin", "root", "dev"]:
        # Another specific error
        raise InappropriateUsername("Reserved names are not allowed.")
    # ... and 41 other fun ways to fail

try:
    check_user_input("my_user", "short")
except TastyErrors as e:
    # Catch ALL 43 custom exceptions from the package in one go!
    print(f"❌ Application Error Caught: {type(e).__name__}")
    print(f"   Reason: {e}")
except Exception as e:
    # Catch general Python errors (like BadType)
    print(f"Python Standard Error: {type(e).__name__}")
  • 2: Dynamic Raising ( new and tasty! ) Use the TastyRaiser class to dynamically look up and raise exceptions using their string names. Perfect for configuration files or API gateways where the error name is dynamic! Just use the following steps, and you're good to go!

Step 1: Import it

from tastyerrors import TastyRaiser

Step 2: Get the Raiser rolling!

# Initialize the raiser
raiser = TastyRaiser()

Step 3: Set your error message ❎

raiser.set_error_msg('Eat, sleep, code')

Step 4: Raise your error, dude!

# Syntax : raiser.RaiseTasty([error string])
raiser.RaiseTasty('AuthError')

📋 Exception Documentation (The Full Menu)

We currently feature 43 exceptions across 7 delicious categories. Yes, that's right—we blew past the answer to the universe (42) and gave you one more for good measure.

Featured Category: Color Picking (New in v2025.0.1)

Exception Class Inherits From When to Use
ColorError InputError Base class for all color-related validation issues.
InvalidColorFormatError ColorError The user gave you "banana" when you needed a hex code (#FFD700).
ColorNotInPaletteError ColorError The color is valid, but your design constraints (e.g., brand guidelines) don't allow it.

Full List by Category (Excluding Base Classes)

Category Base Class Examples
Authentication AuthError UsernameNotFound, IncorrectPassword, RetryLimitExceededError
Validation BadPassword / BadUsername PasswordTooShort, NotUniqueUsername, InappropriatePassword
Processing ProcessingError RateLimitExceededError, APIException, NetworkError
Data Integrity ProcessingError DataIntegrityError, DataNotFoundError
Financial/Inventory TastyErrors InsufficientFundsError, InventoryError
System & Resources SystemError MemoryExhaustedError, ConcurrencyException, DependencyError
Network/Built-in Wrappers (Various Built-ins) ServiceNotAvailable, TimeOutException, BadType

🚀Changelog

🧑‍🚀v2025.0.2

This IS the ultimate release of TastyErrors. We've brought you groundbreaking features.

  • We've created the all-new TastyRaiser utility. It is built to use dynamic lookup, guaranteeing stability and predictability when raising exceptions by string name.
  • Documentation Refinement: We've updated README.md to clearly demonstrate the two main usage patterns: explicit import/catch and dynamic raising.

🧑‍🚀 Release Notes: v2025.0.1

This is the big one. We didn't just add features; we rebuilt the kitchen foundation.

BREAKING CHANGES (And Why They Are Good)

  • Goodbye BaseException: All custom classes now inherit from the standard Python Exception class (via TastyErrors), meaning your users' code won't accidentally catch critical system errors like SystemExit or KeyboardInterrupt. You must now catch TastyErrors instead of previous base classes.

Features & Expansion (The 43 Club)

  • New Base Class: Introduced TastyErrors as the single root catch-all for the entire library.
  • New Exceptions: Added 5 new, highly requested classes, bringing the total count to 43:
    • RateLimitExceededError
    • DataIntegrityError
    • ColorError
    • InvalidColorFormatError
    • ColorNotInPaletteError
  • Professional Docstrings: Every single class now has a clear, professional docstring explaining its intended use case.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

tastyerrors-2025.0.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file tastyerrors-2025.0.2-py3-none-any.whl.

File metadata

  • Download URL: tastyerrors-2025.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tastyerrors-2025.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c40e317c139fc5993112918efb282ba4cdb75752ab9fe1544462cae2663ed2a4
MD5 9ac082839f846f20cc45e3e2b9de0c67
BLAKE2b-256 5beffe5cd889b1db4c0db9fa5688698b3bee62ceb83cc9cf6c3f90b3601dcf0b

See more details on using hashes here.

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