Skip to main content

Beginner-friendly Python error explainer

Project description

py-errorex

Beginner-friendly Python error explainer

py-errorex enhances Python error messages by providing clear explanations, reasons, and actionable fixes — helping beginners debug faster and understand their mistakes.


Features

  • Explains Python errors in simple language
  • Shows why the error happened
  • ️ Suggests practical fixes
  • Works instantly with any Python script
  • Focused on common beginner mistakes

Installation

Install from PyPI:

pip install py-errorex

Or install locally:

pip install .

Usage

Just enable ErrorX at the top of your script:

import errorex

errorex.enable()

data = None
print(len(data))

Default Python Error

TypeError: object of type 'NoneType' has no len()

With py-errorex

❌ TypeError: object of type 'NoneType' has no len()
👉 You are using something that is None

📍 File: app.py
🔢 Line: 4
👉 Code: print(len(data))

💡 Why:
The variable was never initialized or became None

👉 Fixes:
 - Initialize the variable before using it
 - Check if value is None
 - Use condition: if data is not None

Supported Errors

Currently supports:

  • TypeError (NoneType, incompatible types)
  • IndexError
  • KeyError
  • ZeroDivisionError
  • AttributeError
  • ValueError
  • FileNotFoundError

More patterns coming soon


How It Works

py-errorex hooks into Python’s global exception system:

sys.excepthook

When an error occurs:

  1. Captures traceback
  2. Identifies error type
  3. Matches known patterns
  4. Generates explanation + fixes
  5. Displays beginner-friendly output

Example

import errorex

errorex.enable()

arr = [1, 2, 3]
print(arr[5])

Output

❌ IndexError: list index out of range
👉 You are accessing an index that doesn't exist

💡 Why:
The index is greater than the list size

👉 Fixes:
 - Check list length using len(list)
 - Ensure index is within bounds
 - Use safe loops like: for item in list

Future Improvements

  • Colored terminal output
  • Smarter context-aware explanations
  • IDE / VS Code extension
  • More error patterns

Contributing

Contributions are welcome!

You can:

  • Add new error patterns
  • Improve explanations
  • Enhance formatting

License

MIT License


Support

If you found this useful, consider giving it a ⭐ on GitHub!


Made for learners, by a learner

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

py_errorex-0.1.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

py_errorex-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file py_errorex-0.1.2.tar.gz.

File metadata

  • Download URL: py_errorex-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for py_errorex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a6e58cff2fc56ffff1665932245c194ac5ecd0d1a0c29e5986697dfc3bf49f09
MD5 1e6dbe309c44fb8246c6db8e3e0ebd0e
BLAKE2b-256 358d1c8fae04e4cf01cb39f47cf1cf319dff752d36b0a081e4057df1918c347f

See more details on using hashes here.

File details

Details for the file py_errorex-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_errorex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for py_errorex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eadc8b23ffe8a2b70ac44e4100637c0f74b774638bcfa6a56fc91ef2f08e07ef
MD5 28f505cdf7f0457558e5c8bc79760274
BLAKE2b-256 6489dab2efb2bf8261dbf293c05e4f9e0b60884e7c36c6ff5751c8adfec46c11

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