rust-errors

Map Rust enums to TypeScript discriminated unions for Tauri error handling.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/ThePyProgrammer/prism --skill rust-errors-thepyprogrammer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-errors
Source: https://github.com/ThePyProgrammer/prism/tree/main/.claude/skills/rust-errors
Command: npx skills add https://github.com/ThePyProgrammer/prism --skill rust-errors-thepyprogrammer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the challenge of inconsistent error communication between Rust backends and TypeScript frontends in Tauri applications, preventing fragile error handling and nested, awkward data structures.

Core Features & Use Cases

  • Discriminated Union Pattern: Implements internally-tagged enums in Rust that map cleanly to TypeScript discriminated unions.
  • Type-Safe Validation: Provides patterns for using arktype to validate error payloads at the runtime boundary.
  • Use Case: When building a Tauri command that might fail for multiple reasons, such as GPU errors or model loading issues, this skill ensures the frontend receives a consistent object with name and message fields for exhaustive switch-case handling.

Quick Start

Apply the rust-errors pattern to your Tauri command by defining an internally tagged enum with serde and validating the result in TypeScript using arktype.

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 application frontend?

Standardizing Rust-to-TypeScript error handling solves inconsistent cross-language communication by mapping Rust enums to TypeScript discriminated unions. This prevents fragile error handling and nested awkward data structures in Tauri applications.

What is the best way to pass Rust enum errors to TypeScript as discriminated unions?

You can validate error payloads at the runtime boundary by using arktype on the frontend side. This provides type-safe validation for the error objects serialized from the Rust backend, ensuring runtime type safety.

Do I need serde and arktype to standardize error handling between Rust and TypeScript?

This approach is specifically designed for Tauri applications to ensure the frontend receives a consistent object with name and message fields. It handles multiple failure reasons, such as GPU errors or model loading issues, through exhaustive switch-case handling.

How do I validate serialized Rust error payloads in TypeScript at runtime?

Yes, this approach supports Tauri commands that might fail for multiple reasons, such as GPU errors or model loading issues. It ensures the frontend receives a consistent object with name and message fields for exhaustive switch-case handling.