polyglot-error-handling-standardization

Standardize error handling across FFI boundaries with language-specific patterns.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill polyglot-error-handling-standardization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: polyglot-error-handling-standardization
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.codex/skills/polyglot-error-handling-standardization
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill polyglot-error-handling-standardization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexity of managing errors consistently across different programming languages when interacting through Foreign Function Interfaces (FFI), ensuring robust and predictable error handling.

Core Features & Use Cases

  • FFI Error Conversion: Standardizes how errors are converted between Rust and host languages (Python, JavaScript, Ruby, Go, Java).
  • Context Preservation: Ensures error messages, codes, and relevant data are maintained across language boundaries.
  • Language-Specific Patterns: Provides idiomatic error handling examples for Python, JavaScript/TypeScript, Ruby, Go, and Java.
  • Use Case: When a Rust library function fails, this Skill ensures the error is translated into a Python ValueError with all original context intact, preventing silent failures or loss of critical debugging information.

Quick Start

Review the FFI boundary checklist to ensure all error handling requirements are met.

Frequently Asked Questions about polyglot-error-handling-standardization

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

FAQPage Schema
How do I standardize error handling across FFI boundaries in polyglot environments?

Standardizing error handling across FFI boundaries involves defining conversion strategies that preserve error context, including messages, codes, source locations, and cause chains, to prevent silent failures when bridging languages like Rust, Python, and Go.

How do I convert Rust library errors into Python exceptions without losing context?

Converting Rust errors to Python requires mapping them to idiomatic exceptions like ValueError while preserving the original message, error code, and cause chain to ensure debugging information remains intact across the boundary.

What are common anti-patterns for polyglot error handling across language boundaries?

Common anti-patterns include losing error context during conversion, relying on string-based error codes, and dropping cause chains, all of which lead to silent failures and make debugging across FFI boundaries difficult.

Does this approach provide idiomatic error handling patterns for Go and Java?

Yes, this approach provides language-specific idiomatic error handling patterns for Go, Java, JavaScript, Python, and Ruby, ensuring errors are translated appropriately into each language's native error structures while maintaining context.

Why do my errors fail silently when calling foreign functions through an FFI?

Errors fail silently across FFI when conversion strategies drop critical context like source locations or cause chains, preventing the host language from properly surfacing the original failure and complicating debugging.

What is the best way to preserve error cause chains when exposing Rust libraries to JavaScript?

The best way to preserve cause chains is to implement standardized FFI error conversion that explicitly maps Rust error sources to JavaScript error structures, ensuring the full context of the original failure is maintained.