rust-errors
SKILL.md
Rust to TypeScript Error Handling
Reference Repositories
- Tauri — Desktop app framework (source of Rust-to-TypeScript error patterns)
When to Apply This Skill
Use this pattern when you need to:
- Send Rust errors through Tauri commands to TypeScript clients.
- Define Rust enums that serialize into discriminated union error shapes.
- Validate unknown error payloads in TypeScript before switching on variants.
- Keep cross-language error payloads consistent with
nameandmessagefields. - Avoid serde tagging patterns that produce nested, awkward TypeScript shapes.
Discriminated Union Pattern for Errors
When passing errors from Rust to TypeScript through Tauri commands, use internally-tagged enums to create discriminated unions that TypeScript can handle naturally.