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.2.tar.gz (7.0 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.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whycrash-1.0.2.tar.gz
  • Upload date:
  • Size: 7.0 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.2.tar.gz
Algorithm Hash digest
SHA256 8b4ae95759607ea792f35f959a2abe1d81eebe9a204f638075c0dd807782fc45
MD5 5bc0a8d4b899ed028533cc2692286a9f
BLAKE2b-256 04cd9872beb37a458b9e36d1f147207ec8ada43b7d90b765586b3febe62c25da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whycrash-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46cc97cbcd32da1f0f51f98b2cae22598ca825a5b7cbcd05339fcba538a3f1a4
MD5 89d43131a4f37134a60344ec9084137a
BLAKE2b-256 1f960f7f6845119b4b353ad032eba02540d6ce31b967b860fcf50e177a42e314

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