rust-errors

Standardize Rust-to-TypeScript error shapes for Tauri commands using serde internally tagged enums.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/TrollHeap/dotfiles --skill rust-errors-trollheap
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-errors
Source: https://github.com/TrollHeap/dotfiles/tree/main/ai-config/.claude/templates/tauri-solidjs/.claude/skills/rust-errors
Command: npx skills add https://github.com/TrollHeap/dotfiles --skill rust-errors-trollheap

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust-to-TypeScript error handling across the Rust-Tauri boundary can be brittle and hard to maintain. This pattern provides a clean approach to modeling errors so TypeScript can reliably interpret and present errors from Rust.

Core Features & Use Cases

  • Internal tagging for discriminated unions using serde to serialize error data into a predictable JSON shape.
  • Clear guidance for mapping Rust errors (ModelLoadError, GpuError, TranscriptionError, etc.) to TypeScript handling paths in Tauri commands.
  • Best practices for naming conventions, error variant design, and implementing safe cross-language error handling across the Rust–TypeScript boundary.

Quick Start

Define an internally tagged Rust error enum with serde tagging and expose a corresponding TypeScript type to handle the error in the frontend.

Frequently Asked Questions about rust-errors

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

FAQPage Schema
How do I handle Rust errors in a Tauri app with TypeScript?

Standardizing Rust errors for TypeScript involves using internally tagged enums with serde to serialize error data into a predictable JSON shape. This pattern ensures a robust cross-language boundary for Tauri commands.

What is the best way to serialize Rust error enums for TypeScript discriminated unions?

Using internal tagging via serde is the best way to serialize Rust error enums for TypeScript discriminated unions. This approach creates a stable JSON representation that maps variants directly to TypeScript handling paths.

How does serde internal tagging work for cross-language error handling?

Serde internal tagging works for cross-language error handling by embedding a discriminator field within the JSON representation of your Rust error enum. This allows TypeScript to safely interpret and present errors using standard discriminated union checks.

Can I map custom Rust error variants like ModelLoadError to TypeScript types in Tauri?

Yes, you can map custom Rust error variants like ModelLoadError or GpuError to TypeScript types in Tauri. The pattern provides clear guidance for naming conventions and error variant design across the boundary.

Why is Rust to TypeScript error handling brittle in Tauri commands?

Rust to TypeScript error handling becomes brittle in Tauri commands without consistent JSON shapes. Standardizing error surfaces with a discriminated union pattern and serde ensures a stable representation to resolve this maintenance issue.