skillfed

error-handling-debugging

Master error handling across Rust and TypeScript in Tauri applications. Learn custom error types, exception chains, API response patterns, and debugging techniques using tracing and structured logging. Covers database errors, command failures, and React error boundaries.

Error Handling & Debugging Skill provides patterns for managing errors and debugging issues in Tauri applications built with Rust and TypeScript.

AI-generated summary based on this skill's SKILL.md

4 3 MIT updated by cacr92

Install

cacr92/WeReply/error-handling-debugging · repository language: Python

git clone https://github.com/cacr92/WeReply
cp -r WeReply/.claude/skills/error-handling-debugging ~/.claude/skills/error-handling-debugging
npx skillfed install cacr92/WeReply/error-handling-debugging

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do you handle errors in Rust Tauri applications?

error-handling-debugging teaches custom error types using thiserror and anyhow for building exception chains in Tauri. Define Result types wrapping your error enum, use the ? operator for propagation, and serialize errors as JSON responses to the frontend. Tauri's command macro automatically converts Rust errors into TypeScript-compatible responses, letting you handle failures gracefully in React components.

What are TypeScript error handling best practices for async code?

error-handling-debugging covers try-catch patterns with async/await, proper error typing to avoid 'unknown' types, and discriminated unions for structured error responses. Wrap async operations in try blocks, catch specific error conditions, and propagate meaningful context. Use type guards to narrow error types before accessing properties, preventing runtime crashes from unexpected error shapes.

How do you debug Tauri command failures and deserialization errors?

error-handling-debugging addresses debugging Tauri command failures by enabling structured logging with tracing and instrumentation. Check type mismatches in command signatures—Specta attributes must match Rust types exactly. Use console logs on the frontend to inspect serialized responses, enable Tauri's debug mode, and validate JSON payloads. Database errors like 'locked' typically indicate concurrent access; use connection pooling and retry logic with exponential backoff.

How do you set up structured logging and tracing in Rust?

error-handling-debugging demonstrates rust tracing setup using the tracing crate with subscribers for capturing instrumentation events. Initialize a tracing subscriber in your main function, use #[instrument] macros on functions to auto-log entry/exit, and emit span events for diagnostics. Combine with anyhow for error chains that preserve context through the call stack, making failures easier to trace in production logs.

What's the proper way to implement React error boundaries?

error-handling-debugging covers React error boundary implementation using class components with componentDidCatch lifecycle methods. Wrap risky subtrees to catch rendering errors and display fallback UI. Pair with useEffect cleanup patterns to prevent memory leaks from subscriptions, and use dependency arrays correctly to avoid hook warnings. Combine with Tauri command error responses for comprehensive frontend error handling.

How do you implement retry logic with exponential backoff in Rust?

error-handling-debugging teaches retry logic by wrapping async operations in loops with exponential backoff delays. Use tokio::time::sleep to introduce delays between attempts, calculate backoff as base_delay * 2^attempt, and set max retry counts to prevent infinite loops. Combine with custom error types to distinguish retryable errors from permanent failures, enabling graceful degradation when services are temporarily unavailable.

SKILL.md

rendered from the published skill — quoted content, verbatim

Error Handling & Debugging Skill

Comprehensive error handling and debugging strategies for Tauri + Rust + React applications.

Rust Error Handling

Error Chain with anyhow
use anyhow::{Context, Result, anyhow, bail};

pub async fn complex_operation(&self) -> Result<Output> {
    let data = self.fetch_data()
        .await
        .context("获取数据失败")?;

    if data.is_empty() {
        bail!("数据为空,无法继续处理");
    }

    let processed = self.process_data(&data)
        .context("处理数据失败")?;

    Ok(processed)
}
ApiResponse Conversion Pattern

```rust use crate::utils::error::{api_err, api_ok, ApiResponse};

[tauri::command]

[specta::specta]

pub async fn handle_formula_request( dto: FormulaDto, state: State<'_, TauriAppState>, ) -> ApiResponse<Formula> { // Using with_service helper for automatic error conversion with_service(state, |ctx| async move {

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 2 files
.claude/skills/error-handling-debugging/SKILL.md
.claude/skills/error-handling-debugging/skill.json

Related skills

Tags

exception-handling diagnostic-logging resilience-patterns type-safety desktop-debugging recovery-strategies async-error-flow instrumentation-tracing