Skip to main content

A highly automatic AI error handler and code fixer using OpenRouter and Minimax.

Project description

🚀 WhyCrash

WhyCrash is a fully automatic AI assistant for error handling in Python. When your code crashes, WhyCrash intercepts the error, analyzes it using neural networks (OpenRouter + Minimax), gathers context from your local project files, and provides the cause along with an AUTOMATIC CODE FIX.

Did your code crash? The AI will explain why and automatically replace the broken file with the fixed one (if you allow it).

GitHub license Python Versions

✨ Main Features

  • 🧠 Smart Traceback Analysis: Understands not just the line with the error but also gathers imported local project files.
  • 🛠️ Auto-Fixing: Proposes a ready-made fix and can rewrite the target Python files itself.
  • 🎯 Precise Control: You decide where to catch errors: in the entire project, in a single function, or in a specific block of code.
  • 🎨 Beautiful Interface: Uses the rich library for nice windows and terminal formatting.

📦 Installation

pip install WhyCrash

(Requires requests, rich, and questionary — they will install automatically)


🛠️ How to Use

You have 4 ways to control which errors WhyCrash should catch. Choose the one that fits best!

1. Global Intercept (Easiest)

If you want any unhandled error in your program to be analyzed by the AI:

import WhyCrash

# Enable error catching for the whole script
WhyCrash.debug()

# If the code crashes below, WhyCrash comes to the rescue!
print(1 / 0)

2. Dynamic Toggle (start & end)

If you have a large block of code and want to turn on smart analysis right before it, and turn it off right after:

import WhyCrash

# ... normal code without WhyCrash ...

WhyCrash.start_debug()  # Turn on the interceptor

a = "text"
b = int(a)  # <-- This error will go to the AI!

WhyCrash.end_debug()    # Turn off the interceptor (returns to standard behavior)

3. Decorator for Specific Functions @catch_errors

If you are only concerned about the reliability of a specific function, you can wrap it in a decorator. If the function crashes, WhyCrash will trigger, while system errors outside of it remain untouched.

from WhyCrash import catch_errors

@catch_errors
def my_danger_function():
    # If it breaks here — WhyCrash will trigger
    file = open("no_exist.txt", "r")

def normal_function():
    # And if it breaks here — standard Python traceback
    pass

my_danger_function()

4. Context Manager with catch_block()

For the most precise control, if you expect a failure in literally 2 specific lines of code:

from WhyCrash import catch_block

print("Starting work...")
text = "100"

with catch_block():
    # Only code inside this block is monitored
    number = int(text)
    result = number / 0  # This will trigger an error sent to WhyCrash!

print("This code will not execute if there was an error above.")

🛑 How to Ignore Error Catching?

WhyCrash only analyzes unhandled exceptions. If you want an error in your code not to reach WhyCrash and the script to keep running, simply use a standard try...except block:

import WhyCrash
WhyCrash.debug()

try:
    int("letter")
except ValueError:
    print("Error caught, it won't reach WhyCrash. Moving on!")

⚙️ Under the Hood

  • OpenRouter & Minimax — Responsible for code analysis, "Reasoning," and generating fix files.
  • Traceback Walking — The script automatically follows the error chain, finds all your .py files involved, reads them, and sends them to the AI as context.
  • Rich — Beautiful console UI (colors, panels, Markdown formatting).

Made with ❤️ to save developers' nerves!


🌍 Languages: Русский | Deutsch

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

whycrash-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

whycrash-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file whycrash-1.0.0.tar.gz.

File metadata

  • Download URL: whycrash-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for whycrash-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b3aa026d37a12844af8d11908d979713ba9597d356f8c252d01371d7e13f7e3
MD5 a92dc963819d2bf2cf424be16314b9e1
BLAKE2b-256 49c1195a2a8a46601f3ed0fd485028cd7f142806ef307c8900d4f9fec6789bcb

See more details on using hashes here.

File details

Details for the file whycrash-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: whycrash-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for whycrash-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b78cf1d4bac0eb2796268d049b0df78c9c7a07eb567aa8809e76b526ae1fbda
MD5 97e32e2d23c8f16a36c0f1b793585d45
BLAKE2b-256 41c292b738783e4f761ecbbea906deab21011e3cf6df1e866341c470d064743c

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