Crashtest

0.4.1 · active · verified Sat Mar 28

Crashtest is a Python library designed to simplify the handling and inspection of exceptions, providing tools to manage Python errors with ease. It is currently at version 0.4.1 and has a moderate release cadence, with recent updates focused on stability and type hinting.

Warnings

Install

Imports

Quickstart

Demonstrates how to use the `Inspector` class to extract detailed information from a caught exception, including its type, message, and the full stack trace with code context.

import sys
from crashtest import Inspector

def might_fail():
    a = 1
    b = 0
    return a / b

try:
    might_fail()
except Exception as e:
    inspector = Inspector(e)
    print(f"Exception type: {inspector.type}")
    print(f"Exception message: {inspector.message}")
    print("Stack Trace:")
    for frame in inspector.frames:
        print(f"  File: {frame.file}, Line: {frame.lineno}, Function: {frame.name}")
        print(f"    Code: {frame.line.strip() if frame.line else 'N/A'}")

view raw JSON →