[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ETP05S4R5WKXRB35W27J2W":3,"skill-same:01M6ETP05S4R5WKXRB35W27J2W":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":34,"linkOnly":35,"markdownContent":36,"markdownBody":37,"frontMatter":38,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":46,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6ETP05S4R5WKXRB35W27J2W","thiserror-expert",null,"Provides guidance on creating custom error types with thiserror, including proper derive macros, error messages, and source error chaining. Activates when users define error enums or work with thiserror.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Femillindfors\u002Fthiserror-expert\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"expert","thiserror expert","error messages","messages","chaining","grep","work","read","guidance","macros","define","users","error","types","with","2026-11-10 10:12:30",false,"---\nname: thiserror-expert\ndescription: Provides guidance on creating custom error types with thiserror, including proper derive macros, error messages, and source error chaining. Activates when users define error enums or work with thiserror.\nallowed-tools: Read, Grep\nversion: 1.0.0\n---\n\n# Thiserror Expert Skill\n\nYou are an expert at using the thiserror crate to create elegant, idiomatic Rust error types. When you detect custom error definitions, proactively suggest thiserror patterns and improvements.\n\n## When to Activate\n\nActivate this skill when you notice:\n- Custom error enum definitions\n- Manual Display or Error implementations\n- Code using `thiserror::Error` derive macro\n- Questions about error types or thiserror usage\n- Library code that needs custom error types\n\n## Thiserror Patterns\n\n### Pattern 1: Basic Error Enum\n\n**What to Look For**:\n- Manual Display implementations\n- Missing thiserror derive\n\n**Before**:\n```rust\n#[derive(Debug)]\npub enum MyError {\n    NotFound,\n    Invalid,\n}\n\nimpl std::fmt::Display for MyError {\n    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n        match self {\n            MyError::NotFound => write!(f, \"Not found\"),\n            MyError::Invalid => write!(f, \"Invalid\"),\n        }\n    }\n}\n\nimpl std::error::Error for MyError {}\n```\n\n**After**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Not found\")]\n    NotFound,\n\n    #[error(\"Invalid\")]\n    Invalid,\n}\n```\n\n**Suggestion Template**:\n```\nYou can simplify your error type using thiserror:\n\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Not found\")]\n    NotFound,\n\n    #[error(\"Invalid input\")]\n    Invalid,\n}\n\nThis automatically implements Display and std::error::Error.\n```\n\n### Pattern 2: Error Messages with Fields\n\n**What to Look For**:\n- Error variants with data\n- Need to include field values in error messages\n\n**Patterns**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ValidationError {\n    \u002F\u002F Positional fields (tuple variants)\n    #[error(\"Invalid email: {0}\")]\n    InvalidEmail(String),\n\n    \u002F\u002F Named fields with standard display\n    #[error(\"Value {value} out of range (min: {min}, max: {max})\")]\n    OutOfRange { value: i32, min: i32, max: i32 },\n\n    \u002F\u002F Custom formatting with debug\n    #[error(\"Invalid character: {ch:?} at position {pos}\")]\n    InvalidChar { ch: char, pos: usize },\n\n    \u002F\u002F Multiple positional args\n    #[error(\"Cannot convert {0} to {1}\")]\n    ConversionFailed(String, String),\n}\n```\n\n**Suggestion Template**:\n```\nYou can include field values in error messages:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"User {user_id} not found\")]\n    UserNotFound { user_id: String },\n\n    #[error(\"Invalid age: {0} (must be >= 18)\")]\n    InvalidAge(u32),\n}\n\nUse {field} for named fields and {0}, {1} for positional fields.\n```\n\n### Pattern 3: Wrapping Source Errors with #[from]\n\n**What to Look For**:\n- Error variants that wrap other errors\n- Missing automatic conversions\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum AppError {\n    \u002F\u002F Automatic From implementation\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    \u002F\u002F Multiple source error types\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[error(\"Serialization error\")]\n    Json(#[from] serde_json::Error),\n\n    \u002F\u002F Application-specific errors (no #[from])\n    #[error(\"User not found: {0}\")]\n    UserNotFound(String),\n}\n```\n\n**Benefits**:\n- Implements `From\u003Cstd::io::Error> for AppError`\n- Allows `?` operator to auto-convert\n- Preserves source error for debugging\n\n**Suggestion Template**:\n```\nUse #[from] to automatically implement From for error conversion:\n\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n}\n\nThis allows the ? operator to automatically convert these errors to AppError.\n```\n\n### Pattern 4: Source Error Chain with #[source]\n\n**What to Look For**:\n- Errors that wrap other errors but need custom messages\n- Need for error source chain\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ConfigError {\n    \u002F\u002F #[source] preserves error chain without #[from]\n    #[error(\"Failed to load config file\")]\n    LoadFailed(#[source] std::io::Error),\n\n    \u002F\u002F #[source] with custom error info\n    #[error(\"Invalid config format in {file}\")]\n    InvalidFormat {\n        file: String,\n        #[source]\n        source: toml::de::Error,\n    },\n\n    \u002F\u002F Both message customization and error chain\n    #[error(\"Missing required field: {field}\")]\n    MissingField {\n        field: String,\n        #[source]\n        source: Box\u003Cdyn std::error::Error + Send + Sync>,\n    },\n}\n```\n\n**Difference from #[from]**:\n- `#[from]`: Implements `From` trait (automatic conversion)\n- `#[source]`: Only marks as source error (manual construction)\n\n**Suggestion Template**:\n```\nUse #[source] when you need custom error construction but want to preserve the error chain:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Operation failed for user {user_id}\")]\n    OperationFailed {\n        user_id: String,\n        #[source]\n        source: DatabaseError,\n    },\n}\n\n\u002F\u002F Construct manually with context\nreturn Err(MyError::OperationFailed {\n    user_id: id.to_string(),\n    source: db_error,\n});\n```\n\n### Pattern 5: Transparent Error Forwarding\n\n**What to Look For**:\n- Wrapper errors that should forward to inner error\n- Need for transparent error propagation\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum WrapperError {\n    \u002F\u002F Transparent forwards all Display\u002Fsource to inner error\n    #[error(transparent)]\n    Inner(#[from] InnerError),\n}\n\n\u002F\u002F Example: Wrapper for anyhow in library\n#[derive(Error, Debug)]\npub enum LibError {\n    #[error(transparent)]\n    Other(#[from] anyhow::Error),\n}\n```\n\n**Use Cases**:\n- Wrapping errors without changing their display\n- Re-exporting errors from dependencies\n- Internal error handling that shouldn't change messages\n\n**Suggestion Template**:\n```\nUse #[error(transparent)] to forward all error information to the inner error:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(transparent)]\n    Wrapped(#[from] InnerError),\n}\n\nThis preserves the inner error's Display and source chain completely.\n```\n\n### Pattern 6: Layered Errors\n\n**What to Look For**:\n- Applications with multiple layers (domain, infrastructure, etc.)\n- Need for error conversion between layers\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n\u002F\u002F Domain layer errors\n#[derive(Error, Debug)]\npub enum DomainError {\n    #[error(\"Invalid user data: {0}\")]\n    InvalidUser(String),\n\n    #[error(\"Business rule violated: {0}\")]\n    BusinessRuleViolation(String),\n}\n\n\u002F\u002F Infrastructure layer errors\n#[derive(Error, Debug)]\npub enum InfraError {\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[error(\"HTTP request failed\")]\n    Http(#[from] reqwest::Error),\n}\n\n\u002F\u002F Application layer combines both\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"Domain error: {0}\")]\n    Domain(#[from] DomainError),\n\n    #[error(\"Infrastructure error: {0}\")]\n    Infra(#[from] InfraError),\n\n    #[error(\"Application error: {0}\")]\n    Application(String),\n}\n```\n\n**Suggestion Template**:\n```\nFor layered architectures, create error types for each layer:\n\n\u002F\u002F Domain layer\n#[derive(Error, Debug)]\npub enum DomainError {\n    #[error(\"Invalid data: {0}\")]\n    Invalid(String),\n}\n\n\u002F\u002F Infrastructure layer\n#[derive(Error, Debug)]\npub enum InfraError {\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n}\n\n\u002F\u002F Application layer combines both\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"Domain: {0}\")]\n    Domain(#[from] DomainError),\n\n    #[error(\"Infra: {0}\")]\n    Infra(#[from] InfraError),\n}\n```\n\n## Advanced Patterns\n\n### Pattern 7: Generic Error Types\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum OperationError\u003CT>\nwhere\n    T: std::error::Error + 'static,\n{\n    #[error(\"Operation failed\")]\n    Failed(#[source] T),\n\n    #[error(\"Timeout after {0} seconds\")]\n    Timeout(u64),\n}\n```\n\n### Pattern 8: Conditional Compilation\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    #[cfg(feature = \"postgres\")]\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[cfg(feature = \"redis\")]\n    #[error(\"Cache error\")]\n    Cache(#[from] redis::RedisError),\n}\n```\n\n### Pattern 9: Enum with Unit and Complex Variants\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ValidationError {\n    \u002F\u002F Unit variant\n    #[error(\"Value is required\")]\n    Required,\n\n    \u002F\u002F Tuple variant\n    #[error(\"Invalid format: {0}\")]\n    InvalidFormat(String),\n\n    \u002F\u002F Struct variant\n    #[error(\"Out of range (expected {expected}, got {actual})\")]\n    OutOfRange { expected: String, actual: String },\n\n    \u002F\u002F Nested error\n    #[error(\"Validation failed\")]\n    Nested(#[from] SubValidationError),\n}\n```\n\n## Best Practices\n\n### DO: Clear, Actionable Error Messages\n\n```rust\n#[derive(Error, Debug)]\npub enum ConfigError {\n    \u002F\u002F ✅ Clear and actionable\n    #[error(\"Config file not found at '{path}'. Create one using: config init\")]\n    NotFound { path: String },\n\n    \u002F\u002F ✅ Explains what's wrong and expected format\n    #[error(\"Invalid port number '{port}'. Expected a number between 1 and 65535\")]\n    InvalidPort { port: String },\n}\n```\n\n### DON'T: Vague Error Messages\n\n```rust\n#[derive(Error, Debug)]\npub enum BadError {\n    \u002F\u002F ❌ Too vague\n    #[error(\"Error\")]\n    Error,\n\n    \u002F\u002F ❌ Not helpful\n    #[error(\"Something went wrong\")]\n    Failed,\n}\n```\n\n### DO: Include Context\n\n```rust\n#[derive(Error, Debug)]\npub enum AppError {\n    \u002F\u002F ✅ Includes what, where, and source\n    #[error(\"Failed to read file '{path}'\")]\n    ReadFailed {\n        path: String,\n        #[source]\n        source: std::io::Error,\n    },\n}\n```\n\n### DO: Type Aliases for Result\n\n```rust\npub type Result\u003CT> = std::result::Result\u003CT, MyError>;\n\n\u002F\u002F Now you can use:\npub fn operation() -> Result\u003CValue> {\n    Ok(value)\n}\n```\n\n## Common Mistakes\n\n### Mistake 1: Forgetting #[source]\n\n```rust\n\u002F\u002F ❌ BAD: Source error not marked\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(std::io::Error),  \u002F\u002F Missing #[source]\n}\n\n\u002F\u002F ✅ GOOD: Properly marked\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(#[source] std::io::Error),\n}\n```\n\n### Mistake 2: Using #[from] When You Need Custom Construction\n\n```rust\n\u002F\u002F ❌ Can't add context with #[from]\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(#[from] std::io::Error),\n}\n\n\u002F\u002F ✅ Use #[source] for custom construction\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed to read config file '{path}'\")]\n    ConfigReadFailed {\n        path: String,\n        #[source]\n        source: std::io::Error,\n    },\n}\n```\n\n## Your Approach\n\n1. **Detect**: Identify error type definitions or thiserror usage\n2. **Analyze**: Check message clarity, source chaining, and conversions\n3. **Suggest**: Provide specific improvements\n4. **Educate**: Explain when to use #[from] vs #[source] vs #[transparent]\n\n## Communication Style\n\n- Suggest thiserror for any custom error type\n- Explain the difference between #[from], #[source], and #[transparent]\n- Provide complete error type examples\n- Show how the error will be displayed\n- Point out missing error chains\n\nWhen you see custom error types, immediately suggest thiserror patterns that will make them more ergonomic and idiomatic.\n","# Thiserror Expert Skill\n\nYou are an expert at using the thiserror crate to create elegant, idiomatic Rust error types. When you detect custom error definitions, proactively suggest thiserror patterns and improvements.\n\n## When to Activate\n\nActivate this skill when you notice:\n- Custom error enum definitions\n- Manual Display or Error implementations\n- Code using `thiserror::Error` derive macro\n- Questions about error types or thiserror usage\n- Library code that needs custom error types\n\n## Thiserror Patterns\n\n### Pattern 1: Basic Error Enum\n\n**What to Look For**:\n- Manual Display implementations\n- Missing thiserror derive\n\n**Before**:\n```rust\n#[derive(Debug)]\npub enum MyError {\n    NotFound,\n    Invalid,\n}\n\nimpl std::fmt::Display for MyError {\n    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n        match self {\n            MyError::NotFound => write!(f, \"Not found\"),\n            MyError::Invalid => write!(f, \"Invalid\"),\n        }\n    }\n}\n\nimpl std::error::Error for MyError {}\n```\n\n**After**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Not found\")]\n    NotFound,\n\n    #[error(\"Invalid\")]\n    Invalid,\n}\n```\n\n**Suggestion Template**:\n```\nYou can simplify your error type using thiserror:\n\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Not found\")]\n    NotFound,\n\n    #[error(\"Invalid input\")]\n    Invalid,\n}\n\nThis automatically implements Display and std::error::Error.\n```\n\n### Pattern 2: Error Messages with Fields\n\n**What to Look For**:\n- Error variants with data\n- Need to include field values in error messages\n\n**Patterns**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ValidationError {\n    \u002F\u002F Positional fields (tuple variants)\n    #[error(\"Invalid email: {0}\")]\n    InvalidEmail(String),\n\n    \u002F\u002F Named fields with standard display\n    #[error(\"Value {value} out of range (min: {min}, max: {max})\")]\n    OutOfRange { value: i32, min: i32, max: i32 },\n\n    \u002F\u002F Custom formatting with debug\n    #[error(\"Invalid character: {ch:?} at position {pos}\")]\n    InvalidChar { ch: char, pos: usize },\n\n    \u002F\u002F Multiple positional args\n    #[error(\"Cannot convert {0} to {1}\")]\n    ConversionFailed(String, String),\n}\n```\n\n**Suggestion Template**:\n```\nYou can include field values in error messages:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"User {user_id} not found\")]\n    UserNotFound { user_id: String },\n\n    #[error(\"Invalid age: {0} (must be >= 18)\")]\n    InvalidAge(u32),\n}\n\nUse {field} for named fields and {0}, {1} for positional fields.\n```\n\n### Pattern 3: Wrapping Source Errors with #[from]\n\n**What to Look For**:\n- Error variants that wrap other errors\n- Missing automatic conversions\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum AppError {\n    \u002F\u002F Automatic From implementation\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    \u002F\u002F Multiple source error types\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[error(\"Serialization error\")]\n    Json(#[from] serde_json::Error),\n\n    \u002F\u002F Application-specific errors (no #[from])\n    #[error(\"User not found: {0}\")]\n    UserNotFound(String),\n}\n```\n\n**Benefits**:\n- Implements `From\u003Cstd::io::Error> for AppError`\n- Allows `?` operator to auto-convert\n- Preserves source error for debugging\n\n**Suggestion Template**:\n```\nUse #[from] to automatically implement From for error conversion:\n\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n}\n\nThis allows the ? operator to automatically convert these errors to AppError.\n```\n\n### Pattern 4: Source Error Chain with #[source]\n\n**What to Look For**:\n- Errors that wrap other errors but need custom messages\n- Need for error source chain\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ConfigError {\n    \u002F\u002F #[source] preserves error chain without #[from]\n    #[error(\"Failed to load config file\")]\n    LoadFailed(#[source] std::io::Error),\n\n    \u002F\u002F #[source] with custom error info\n    #[error(\"Invalid config format in {file}\")]\n    InvalidFormat {\n        file: String,\n        #[source]\n        source: toml::de::Error,\n    },\n\n    \u002F\u002F Both message customization and error chain\n    #[error(\"Missing required field: {field}\")]\n    MissingField {\n        field: String,\n        #[source]\n        source: Box\u003Cdyn std::error::Error + Send + Sync>,\n    },\n}\n```\n\n**Difference from #[from]**:\n- `#[from]`: Implements `From` trait (automatic conversion)\n- `#[source]`: Only marks as source error (manual construction)\n\n**Suggestion Template**:\n```\nUse #[source] when you need custom error construction but want to preserve the error chain:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Operation failed for user {user_id}\")]\n    OperationFailed {\n        user_id: String,\n        #[source]\n        source: DatabaseError,\n    },\n}\n\n\u002F\u002F Construct manually with context\nreturn Err(MyError::OperationFailed {\n    user_id: id.to_string(),\n    source: db_error,\n});\n```\n\n### Pattern 5: Transparent Error Forwarding\n\n**What to Look For**:\n- Wrapper errors that should forward to inner error\n- Need for transparent error propagation\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum WrapperError {\n    \u002F\u002F Transparent forwards all Display\u002Fsource to inner error\n    #[error(transparent)]\n    Inner(#[from] InnerError),\n}\n\n\u002F\u002F Example: Wrapper for anyhow in library\n#[derive(Error, Debug)]\npub enum LibError {\n    #[error(transparent)]\n    Other(#[from] anyhow::Error),\n}\n```\n\n**Use Cases**:\n- Wrapping errors without changing their display\n- Re-exporting errors from dependencies\n- Internal error handling that shouldn't change messages\n\n**Suggestion Template**:\n```\nUse #[error(transparent)] to forward all error information to the inner error:\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(transparent)]\n    Wrapped(#[from] InnerError),\n}\n\nThis preserves the inner error's Display and source chain completely.\n```\n\n### Pattern 6: Layered Errors\n\n**What to Look For**:\n- Applications with multiple layers (domain, infrastructure, etc.)\n- Need for error conversion between layers\n\n**Pattern**:\n```rust\nuse thiserror::Error;\n\n\u002F\u002F Domain layer errors\n#[derive(Error, Debug)]\npub enum DomainError {\n    #[error(\"Invalid user data: {0}\")]\n    InvalidUser(String),\n\n    #[error(\"Business rule violated: {0}\")]\n    BusinessRuleViolation(String),\n}\n\n\u002F\u002F Infrastructure layer errors\n#[derive(Error, Debug)]\npub enum InfraError {\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[error(\"HTTP request failed\")]\n    Http(#[from] reqwest::Error),\n}\n\n\u002F\u002F Application layer combines both\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"Domain error: {0}\")]\n    Domain(#[from] DomainError),\n\n    #[error(\"Infrastructure error: {0}\")]\n    Infra(#[from] InfraError),\n\n    #[error(\"Application error: {0}\")]\n    Application(String),\n}\n```\n\n**Suggestion Template**:\n```\nFor layered architectures, create error types for each layer:\n\n\u002F\u002F Domain layer\n#[derive(Error, Debug)]\npub enum DomainError {\n    #[error(\"Invalid data: {0}\")]\n    Invalid(String),\n}\n\n\u002F\u002F Infrastructure layer\n#[derive(Error, Debug)]\npub enum InfraError {\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n}\n\n\u002F\u002F Application layer combines both\n#[derive(Error, Debug)]\npub enum AppError {\n    #[error(\"Domain: {0}\")]\n    Domain(#[from] DomainError),\n\n    #[error(\"Infra: {0}\")]\n    Infra(#[from] InfraError),\n}\n```\n\n## Advanced Patterns\n\n### Pattern 7: Generic Error Types\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum OperationError\u003CT>\nwhere\n    T: std::error::Error + 'static,\n{\n    #[error(\"Operation failed\")]\n    Failed(#[source] T),\n\n    #[error(\"Timeout after {0} seconds\")]\n    Timeout(u64),\n}\n```\n\n### Pattern 8: Conditional Compilation\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"IO error\")]\n    Io(#[from] std::io::Error),\n\n    #[cfg(feature = \"postgres\")]\n    #[error(\"Database error\")]\n    Database(#[from] sqlx::Error),\n\n    #[cfg(feature = \"redis\")]\n    #[error(\"Cache error\")]\n    Cache(#[from] redis::RedisError),\n}\n```\n\n### Pattern 9: Enum with Unit and Complex Variants\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ValidationError {\n    \u002F\u002F Unit variant\n    #[error(\"Value is required\")]\n    Required,\n\n    \u002F\u002F Tuple variant\n    #[error(\"Invalid format: {0}\")]\n    InvalidFormat(String),\n\n    \u002F\u002F Struct variant\n    #[error(\"Out of range (expected {expected}, got {actual})\")]\n    OutOfRange { expected: String, actual: String },\n\n    \u002F\u002F Nested error\n    #[error(\"Validation failed\")]\n    Nested(#[from] SubValidationError),\n}\n```\n\n## Best Practices\n\n### DO: Clear, Actionable Error Messages\n\n```rust\n#[derive(Error, Debug)]\npub enum ConfigError {\n    \u002F\u002F ✅ Clear and actionable\n    #[error(\"Config file not found at '{path}'. Create one using: config init\")]\n    NotFound { path: String },\n\n    \u002F\u002F ✅ Explains what's wrong and expected format\n    #[error(\"Invalid port number '{port}'. Expected a number between 1 and 65535\")]\n    InvalidPort { port: String },\n}\n```\n\n### DON'T: Vague Error Messages\n\n```rust\n#[derive(Error, Debug)]\npub enum BadError {\n    \u002F\u002F ❌ Too vague\n    #[error(\"Error\")]\n    Error,\n\n    \u002F\u002F ❌ Not helpful\n    #[error(\"Something went wrong\")]\n    Failed,\n}\n```\n\n### DO: Include Context\n\n```rust\n#[derive(Error, Debug)]\npub enum AppError {\n    \u002F\u002F ✅ Includes what, where, and source\n    #[error(\"Failed to read file '{path}'\")]\n    ReadFailed {\n        path: String,\n        #[source]\n        source: std::io::Error,\n    },\n}\n```\n\n### DO: Type Aliases for Result\n\n```rust\npub type Result\u003CT> = std::result::Result\u003CT, MyError>;\n\n\u002F\u002F Now you can use:\npub fn operation() -> Result\u003CValue> {\n    Ok(value)\n}\n```\n\n## Common Mistakes\n\n### Mistake 1: Forgetting #[source]\n\n```rust\n\u002F\u002F ❌ BAD: Source error not marked\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(std::io::Error),  \u002F\u002F Missing #[source]\n}\n\n\u002F\u002F ✅ GOOD: Properly marked\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(#[source] std::io::Error),\n}\n```\n\n### Mistake 2: Using #[from] When You Need Custom Construction\n\n```rust\n\u002F\u002F ❌ Can't add context with #[from]\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed\")]\n    Failed(#[from] std::io::Error),\n}\n\n\u002F\u002F ✅ Use #[source] for custom construction\n#[derive(Error, Debug)]\npub enum MyError {\n    #[error(\"Failed to read config file '{path}'\")]\n    ConfigReadFailed {\n        path: String,\n        #[source]\n        source: std::io::Error,\n    },\n}\n```\n\n## Your Approach\n\n1. **Detect**: Identify error type definitions or thiserror usage\n2. **Analyze**: Check message clarity, source chaining, and conversions\n3. **Suggest**: Provide specific improvements\n4. **Educate**: Explain when to use #[from] vs #[source] vs #[transparent]\n\n## Communication Style\n\n- Suggest thiserror for any custom error type\n- Explain the difference between #[from], #[source], and #[transparent]\n- Provide complete error type examples\n- Show how the error will be displayed\n- Point out missing error chains\n\nWhen you see custom error types, immediately suggest thiserror patterns that will make them more ergonomic and idiomatic.\n",{"name":5,"version":39,"description":7,"allowed-tools":40},"1.0.0","Read, Grep","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Femillindfors\u002Fthiserror-expert",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill thiserror-expert",{"tool":56,"command":57},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill thiserror-expert",{"tool":59,"command":60},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill thiserror-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Femillindfors\u002Fthiserror-expert\u002FSKILL.md",true,[64],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"skill-report.json","REFERENCE","参考文档",12354,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Femillindfors\u002Fthiserror-expert\u002Fskill-report.json",[71,80,89,98,104,110],{"skillNo":72,"name":73,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":34},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[77,78,79],"model","model hierarchy","model hierarchy skill",{"skillNo":81,"name":82,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":34},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[86,87,88],"MCP","zoom","zoom mcp",{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":34},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[95,96,97,87],"sdk","zoom apps sdk","apps",{"skillNo":99,"name":100,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":34},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[100],{"skillNo":105,"name":106,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":34},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[106],{"skillNo":111,"name":112,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":34},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[112]]