Skip to main content

Human-readable exception explanations with multi-language support

Project description

Friendly Exceptions

Human-readable error messages for Python. Just import and everything works.

Installation

pip install friendly-exceptions

Quick Start

import friendly_exceptions

# That's it! All errors now have friendly explanations
d = {}
d['missing']  # KeyError with helpful message

Features

  • Zero configuration - just import and it works
  • 15 languages - ru, en, de, fr, es, it, pt, zh, ja, ko, pl, uk, ar, hi, tr
  • 30+ built-in handlers - KeyError, TypeError, ValueError, FileNotFoundError, etc.
  • 20+ integrations - Django, Pydantic, FastAPI, SQLAlchemy, Redis, MongoDB, AWS, Stripe, etc.
  • Web console - visual error dashboard with Supabase sync
  • CLI - global install for any Python project

Language Support

import friendly_exceptions

friendly_exceptions.set_language('ru')  # Русский
friendly_exceptions.set_language('de')  # Deutsch
friendly_exceptions.set_language('zh')  # 中文
friendly_exceptions.set_language('ja')  # 日本語

Integrations

All integrations load automatically if the library is installed:

Category Libraries
Web Django, FastAPI, Pydantic
Database SQLAlchemy, MongoDB, Redis
HTTP Requests, httpx, aiohttp
Cloud AWS/boto3, Firebase, Stripe
Data Pandas, NumPy, Pillow
Bots Telegram, Discord
Testing Pytest
Other OpenAI, Selenium, Subprocess, Asyncio

Server Mode

When running as a server (Django runserver, uvicorn, gunicorn), errors are logged to fe.log:

# settings.py or manage.py
import friendly_exceptions

# Errors now logged to fe.log instead of console

Web Console

python -m friendly_exceptions web-console run -p 8080

Features:

  • Visual error dashboard
  • Supabase authentication
  • Cloud sync for errors and settings
  • Notification settings (Slack, Telegram, Discord, Email)

CLI

Global install for any project:

# Install globally
friendly-exceptions install

# Check status
friendly-exceptions status

# Uninstall
friendly-exceptions uninstall

API

from friendly_exceptions import (
    explain,              # Explain last exception
    explain_exception,    # Explain specific exception
    set_language,         # Set language
    get_language,         # Get current language
    list_languages,       # List available languages
    ErrorCollector,       # Collect multiple errors
)

Example Output

Exception: KeyError: 'user_id'
Traceback (most recent call last):
  File "app.py", line 10, in get_user
    return data['user_id']
KeyError: 'user_id'

💡 Explanation: 🔑 Dictionary does not contain key 'user_id'
📋 Dictionary 'data' contains keys: ['name', 'email']

🔧 How to fix:
1. Check the spelling of the key
2. Use .get() method: dict.get('key', default_value)
3. Check if key exists: 'key' in dict

License

MIT

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

friendly_exceptions-0.3.tar.gz (194.5 kB view details)

Uploaded Source

Built Distribution

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

friendly_exceptions-0.3-py3-none-any.whl (264.3 kB view details)

Uploaded Python 3

File details

Details for the file friendly_exceptions-0.3.tar.gz.

File metadata

  • Download URL: friendly_exceptions-0.3.tar.gz
  • Upload date:
  • Size: 194.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for friendly_exceptions-0.3.tar.gz
Algorithm Hash digest
SHA256 37392167d048dbdcd8bf2898c44b393cfb9f03816411c09a1a3495df448bf58e
MD5 ca790ba03a0159a3db7651d6833a6cc0
BLAKE2b-256 fa4bba1fca539418fb30901d5c2394e046ae003291a5473528b1e8db405a27c5

See more details on using hashes here.

File details

Details for the file friendly_exceptions-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for friendly_exceptions-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 173fe729ad9cb87362445f1bad1a08b28e10b4d9212a80eb9ada2b1cdd2ae7cc
MD5 705aed1b8beba87099b46f92f0327cef
BLAKE2b-256 09b3d575f2869f7d0e5ceb8d24122fd58f3ec58a2b34011916619f9d188a8ee5

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