simarpreet-error-translator

A Python module that intercepts uncaught exceptions and explains them in plain English, with syntax highlighting and exact source context.

Installation

$ pip install simarpreet-error-translator

Usage

Import the module and call install(). From that point on, uncaught exceptions will be intercepted and translated.

import simarpreet_error_translator as et

et.install()

# Any uncaught exception below will be translated
x = 10 / 0

How It Works

Exception Hooking

The module replaces sys.excepthook with a custom handler, capturing uncaught exceptions before Python prints its default traceback.

Remote Error Database

Error explanations are fetched from a hosted JSON file and cached locally for fast lookup by exception type.

Exact Source Line

The final stack frame is inspected and the exact line of code that caused the crash is printed.

ANSI Color Output

Output uses ANSI escape codes for clarity when running in terminals.

Example Output

There was an error: ZeroDivisionError
You tried to divide a number by zero, which is mathematically undefined.
Python says: division by zero

File: main.py, line 6
>>> x = 10 / 0