An awesome library for 40+ additional useful Python exceptions
Project description
🌶️ tastyerrors: The Exception Library That Just Gets It
🤯 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: Catching Them All
Thanks to our beautiful, new architecture, you can catch any error from this entire library with a single line. No more long lists of imports!
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__}")
📋 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 |
🚀 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 PythonExceptionclass (viaTastyErrors), meaning your users' code won't accidentally catch critical system errors likeSystemExitorKeyboardInterrupt. You must now catchTastyErrorsinstead of previous base classes.
Features & Expansion (The 43 Club)
- New Base Class: Introduced
TastyErrorsas the single root catch-all for the entire library. - New Exceptions: Added 5 new, highly requested classes, bringing the total count to 43:
RateLimitExceededErrorDataIntegrityErrorColorErrorInvalidColorFormatErrorColorNotInPaletteError
- Professional Docstrings: Every single class now has a clear, professional docstring explaining its intended use case.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tastyerrors-2025.0.1-py3-none-any.whl.
File metadata
- Download URL: tastyerrors-2025.0.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40dd2ae93a86c7c48ec3f069dee15538b8ed7b7482400b6285b1b299a3bba090
|
|
| MD5 |
efbe3e1eef6d021424517daced0c81dc
|
|
| BLAKE2b-256 |
0a8db4c0ff9055265b782505df86132ce827d07aa0052e582edd6be0531701df
|