Error Handling Strategy

Define error propagation strategies for Python and Rust applications.

115|8|Updated Mar 30, 2025
One-click install
npx skills add https://github.com/Goldziher/spikard --skill error-handling-strategy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Error Handling Strategy
Source: https://github.com/Goldziher/spikard/tree/main/.ai-rulez/skills/error-handling-strategy
Command: npx skills add https://github.com/Goldziher/spikard --skill error-handling-strategy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures that critical errors in Python and Rust applications are handled consistently and reliably, preventing unexpected crashes and data corruption.

Core Features & Use Cases

  • Mandatory Error Bubbling: Guarantees that OSError/RuntimeError (Python + Rust), SystemExit, KeyboardInterrupt, and MemoryError are always propagated.
  • Language-Specific Strategies: Implements tailored error handling for Python (exception-based, inheriting from KreuzbergError) and Rust (Result<T, KreuzbergError>, avoiding .unwrap()).
  • Exception Hierarchy: Defines a clear hierarchy for common error types like ValidationError, ParsingError, OCRError, and MissingDependencyError.
  • Use Case: When a subprocess in your Python application encounters an error, this Skill ensures the error is correctly identified (e.g., by parsing stderr) and handled, rather than being silently ignored.

Quick Start

Configure your Python application to inherit custom exceptions from KreuzbergError.

Frequently Asked Questions about Error Handling Strategy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I ensure critical errors like MemoryError and KeyboardInterrupt are propagated in Python?

To ensure critical error propagation in Python, implement a mandatory bubbling strategy that prevents exceptions like OSError, RuntimeError, SystemExit, KeyboardInterrupt, and MemoryError from being caught.

What is the best way to handle exceptions in Rust without causing unexpected application crashes?

The best way to handle exceptions in Rust for reliability is using Result<T, Error> based propagation, explicitly avoiding .unwrap() calls to safely manage critical errors without crashing.

How do I structure a custom exception hierarchy for parsing and validation errors?

You structure a custom exception hierarchy by inheriting domain-specific types like ValidationError, ParsingError, and OCRError from a base application error, ensuring consistent categorization across your codebase.

Why are my subprocess errors being silently ignored in my Python application?

Subprocess errors are silently ignored when stderr is not parsed and mapped to a critical exception type, a scenario this error handling strategy prevents by explicitly identifying and propagating these failures.

Can I use the same error handling strategy for both Python and Rust applications?

Yes, you can use a unified error handling strategy across both languages by applying language-specific implementations: exception-based inheritance in Python and Result-based propagation in Rust.

When should I not use .unwrap() for error handling in Rust?

You should not use .unwrap() in Rust when building critical applications, as it causes immediate crashes instead of safely propagating errors via the Result<T, Error> type for reliable recovery.