[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AWTG6V7BD1B0VFXGJ7ADZR":3,"skill-same:01M7AWTG6V7BD1B0VFXGJ7ADZR":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7AWTG6V7BD1B0VFXGJ7ADZR","m06-error-handling",null,"CRITICAL: Use for error handling. Triggers: Result, Option, Error, ?, unwrap, expect, panic, anyhow, thiserror, when to panic vs return Result, custom error, error propagation, 错误处理, Result 用法, 什么时候用 panic","wxxb789\u002Fmarkturbo","wxxb789","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F49564443?v=4","01M7AWR3AB19SNE4ATARY9KV3W","01M7AWR3AZ5Y5ADAY47KF3RBRJ",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fm06-error-handling\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: m06-error-handling\ndescription: \"CRITICAL: Use for error handling. Triggers: Result, Option, Error, ?, unwrap, expect, panic, anyhow, thiserror, when to panic vs return Result, custom error, error propagation, 错误处理, Result 用法, 什么时候用 panic\"\nuser-invocable: false\n---\n\n# Error Handling\n\n> **Layer 1: Language Mechanics**\n\n## Core Question\n\n**Is this failure expected or a bug?**\n\nBefore choosing error handling strategy:\n- Can this fail in normal operation?\n- Who should handle this failure?\n- What context does the caller need?\n\n---\n\n## Error → Design Question\n\n| Pattern | Don't Just Say | Ask Instead |\n|---------|----------------|-------------|\n| unwrap panics | \"Use ?\" | Is None\u002FErr actually possible here? |\n| Type mismatch on ? | \"Use anyhow\" | Are error types designed correctly? |\n| Lost error context | \"Add .context()\" | What does the caller need to know? |\n| Too many error variants | \"Use Box\u003Cdyn Error>\" | Is error granularity right? |\n\n---\n\n## Thinking Prompt\n\nBefore handling an error:\n\n1. **What kind of failure is this?**\n   - Expected → Result\u003CT, E>\n   - Absence normal → Option\u003CT>\n   - Bug\u002Finvariant → panic!\n   - Unrecoverable → panic!\n\n2. **Who handles this?**\n   - Caller → propagate with ?\n   - Current function → match\u002Fif-let\n   - User → friendly error message\n   - Programmer → panic with message\n\n3. **What context is needed?**\n   - Type of error → thiserror variants\n   - Call chain → anyhow::Context\n   - Debug info → anyhow or tracing\n\n---\n\n## Trace Up ↑\n\nWhen error strategy is unclear:\n\n```\n\"Should I return Result or Option?\"\n    ↑ Ask: Is absence\u002Ffailure normal or exceptional?\n    ↑ Check: m09-domain (what does domain say?)\n    ↑ Check: domain-* (error handling requirements)\n```\n\n| Situation | Trace To | Question |\n|-----------|----------|----------|\n| Too many unwraps | m09-domain | Is the data model right? |\n| Error context design | m13-domain-error | What recovery is needed? |\n| Library vs app errors | m11-ecosystem | Who are the consumers? |\n\n---\n\n## Trace Down ↓\n\nFrom design to implementation:\n\n```\n\"Expected failure, library code\"\n    ↓ Use: thiserror for typed errors\n\n\"Expected failure, application code\"\n    ↓ Use: anyhow for ergonomic errors\n\n\"Absence is normal (find, get, lookup)\"\n    ↓ Use: Option\u003CT>\n\n\"Bug or invariant violation\"\n    ↓ Use: panic!, assert!, unreachable!\n\n\"Need to propagate with context\"\n    ↓ Use: .context(\"what was happening\")\n```\n\n---\n\n## Quick Reference\n\n| Pattern | When | Example |\n|---------|------|---------|\n| `Result\u003CT, E>` | Recoverable error | `fn read() -> Result\u003CString, io::Error>` |\n| `Option\u003CT>` | Absence is normal | `fn find() -> Option\u003C&Item>` |\n| `?` | Propagate error | `let data = file.read()?;` |\n| `unwrap()` | Dev\u002Ftest only | `config.get(\"key\").unwrap()` |\n| `expect()` | Invariant holds | `env.get(\"HOME\").expect(\"HOME set\")` |\n| `panic!` | Unrecoverable | `panic!(\"critical failure\")` |\n\n## Library vs Application\n\n| Context | Error Crate | Why |\n|---------|-------------|-----|\n| Library | `thiserror` | Typed errors for consumers |\n| Application | `anyhow` | Ergonomic error handling |\n| Mixed | Both | thiserror at boundaries, anyhow internally |\n\n## Decision Flowchart\n\n```\nIs failure expected?\n├─ Yes → Is absence the only \"failure\"?\n│        ├─ Yes → Option\u003CT>\n│        └─ No → Result\u003CT, E>\n│                 ├─ Library → thiserror\n│                 └─ Application → anyhow\n└─ No → Is it a bug?\n        ├─ Yes → panic!, assert!\n        └─ No → Consider if really unrecoverable\n\nUse ? → Need context?\n├─ Yes → .context(\"message\")\n└─ No → Plain ?\n```\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `unwrap()` panic | Unhandled None\u002FErr | Use `?` or match |\n| Type mismatch | Different error types | Use `anyhow` or `From` |\n| Lost context | `?` without context | Add `.context()` |\n| `cannot use ?` | Missing Result return | Return `Result\u003C(), E>` |\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why Bad | Better |\n|--------------|---------|--------|\n| `.unwrap()` everywhere | Panics in production | `.expect(\"reason\")` or `?` |\n| Ignore errors silently | Bugs hidden | Handle or propagate |\n| `panic!` for expected errors | Bad UX, no recovery | Result |\n| Box\u003Cdyn Error> everywhere | Lost type info | thiserror |\n\n---\n\n## Related Skills\n\n| When | See |\n|------|-----|\n| Domain error strategy | m13-domain-error |\n| Crate boundaries | m11-ecosystem |\n| Type-safe errors | m05-type-driven |\n| Mental models | m14-mental-model |\n","# Error Handling\n\n> **Layer 1: Language Mechanics**\n\n## Core Question\n\n**Is this failure expected or a bug?**\n\nBefore choosing error handling strategy:\n- Can this fail in normal operation?\n- Who should handle this failure?\n- What context does the caller need?\n\n---\n\n## Error → Design Question\n\n| Pattern | Don't Just Say | Ask Instead |\n|---------|----------------|-------------|\n| unwrap panics | \"Use ?\" | Is None\u002FErr actually possible here? |\n| Type mismatch on ? | \"Use anyhow\" | Are error types designed correctly? |\n| Lost error context | \"Add .context()\" | What does the caller need to know? |\n| Too many error variants | \"Use Box\u003Cdyn Error>\" | Is error granularity right? |\n\n---\n\n## Thinking Prompt\n\nBefore handling an error:\n\n1. **What kind of failure is this?**\n   - Expected → Result\u003CT, E>\n   - Absence normal → Option\u003CT>\n   - Bug\u002Finvariant → panic!\n   - Unrecoverable → panic!\n\n2. **Who handles this?**\n   - Caller → propagate with ?\n   - Current function → match\u002Fif-let\n   - User → friendly error message\n   - Programmer → panic with message\n\n3. **What context is needed?**\n   - Type of error → thiserror variants\n   - Call chain → anyhow::Context\n   - Debug info → anyhow or tracing\n\n---\n\n## Trace Up ↑\n\nWhen error strategy is unclear:\n\n```\n\"Should I return Result or Option?\"\n    ↑ Ask: Is absence\u002Ffailure normal or exceptional?\n    ↑ Check: m09-domain (what does domain say?)\n    ↑ Check: domain-* (error handling requirements)\n```\n\n| Situation | Trace To | Question |\n|-----------|----------|----------|\n| Too many unwraps | m09-domain | Is the data model right? |\n| Error context design | m13-domain-error | What recovery is needed? |\n| Library vs app errors | m11-ecosystem | Who are the consumers? |\n\n---\n\n## Trace Down ↓\n\nFrom design to implementation:\n\n```\n\"Expected failure, library code\"\n    ↓ Use: thiserror for typed errors\n\n\"Expected failure, application code\"\n    ↓ Use: anyhow for ergonomic errors\n\n\"Absence is normal (find, get, lookup)\"\n    ↓ Use: Option\u003CT>\n\n\"Bug or invariant violation\"\n    ↓ Use: panic!, assert!, unreachable!\n\n\"Need to propagate with context\"\n    ↓ Use: .context(\"what was happening\")\n```\n\n---\n\n## Quick Reference\n\n| Pattern | When | Example |\n|---------|------|---------|\n| `Result\u003CT, E>` | Recoverable error | `fn read() -> Result\u003CString, io::Error>` |\n| `Option\u003CT>` | Absence is normal | `fn find() -> Option\u003C&Item>` |\n| `?` | Propagate error | `let data = file.read()?;` |\n| `unwrap()` | Dev\u002Ftest only | `config.get(\"key\").unwrap()` |\n| `expect()` | Invariant holds | `env.get(\"HOME\").expect(\"HOME set\")` |\n| `panic!` | Unrecoverable | `panic!(\"critical failure\")` |\n\n## Library vs Application\n\n| Context | Error Crate | Why |\n|---------|-------------|-----|\n| Library | `thiserror` | Typed errors for consumers |\n| Application | `anyhow` | Ergonomic error handling |\n| Mixed | Both | thiserror at boundaries, anyhow internally |\n\n## Decision Flowchart\n\n```\nIs failure expected?\n├─ Yes → Is absence the only \"failure\"?\n│        ├─ Yes → Option\u003CT>\n│        └─ No → Result\u003CT, E>\n│                 ├─ Library → thiserror\n│                 └─ Application → anyhow\n└─ No → Is it a bug?\n        ├─ Yes → panic!, assert!\n        └─ No → Consider if really unrecoverable\n\nUse ? → Need context?\n├─ Yes → .context(\"message\")\n└─ No → Plain ?\n```\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `unwrap()` panic | Unhandled None\u002FErr | Use `?` or match |\n| Type mismatch | Different error types | Use `anyhow` or `From` |\n| Lost context | `?` without context | Add `.context()` |\n| `cannot use ?` | Missing Result return | Return `Result\u003C(), E>` |\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why Bad | Better |\n|--------------|---------|--------|\n| `.unwrap()` everywhere | Panics in production | `.expect(\"reason\")` or `?` |\n| Ignore errors silently | Bugs hidden | Handle or propagate |\n| `panic!` for expected errors | Bad UX, no recovery | Result |\n| Box\u003Cdyn Error> everywhere | Lost type info | thiserror |\n\n---\n\n## Related Skills\n\n| When | See |\n|------|-----|\n| Domain error strategy | m13-domain-error |\n| Crate boundaries | m11-ecosystem |\n| Type-safe errors | m05-type-driven |\n| Mental models | m14-mental-model |\n",{"name":5,"description":7,"user-invocable":19},"main","0f3f41ed51c357d4f79561a132514089c1aaa97d",".agents\u002Fskills\u002Fm06-error-handling",0,"https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo","https:\u002F\u002Fgithub.com\u002Fwxxb789","2026-11-15 04:06:53",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add wxxb789\u002Fmarkturbo --skill m06-error-handling",{"tool":36,"command":37},"bunx","bunx skills add wxxb789\u002Fmarkturbo --skill m06-error-handling",{"tool":39,"command":40},"pnpm","pnpm dlx skills add wxxb789\u002Fmarkturbo --skill m06-error-handling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fm06-error-handling\u002FSKILL.md",true,[44,50],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"examples\u002Flibrary-vs-app.md","REFERENCE","参考文档",8210,"https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fm06-error-handling\u002Fexamples\u002Flibrary-vs-app.md",{"path":51,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":52,"sourceHtmlUrl":53},"patterns\u002Ferror-patterns.md",8592,"https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fm06-error-handling\u002Fpatterns\u002Ferror-patterns.md",[55,62,68,75,82,88],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M7AWXVVZ6JEJVFGGT2WBSEN0","hello-diagrams","A valid, fully-populated Agent Skill, shown here so the Skills inspector has something correct to display.","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Fsample\u002F.claude\u002Fskills\u002Fhello-diagrams\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7AWXTNG6ZV6WW5CHJZXJYEC","Broken-Example","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Fsample\u002F.claude\u002Fskills\u002Fbroken-example\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M7AWXS5WN306ENF2MYJYP7VM","valid-skill","A fully conformant skill with every optional field populated.","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Ffixtures\u002Fskills\u002Fskills\u002Fvalid-skill\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M7AWXR0NY08YVHE0G8VTJJ97","a-different-name","The name does not match the directory, which is a conformance warning.","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Ffixtures\u002Fskills\u002Fskills\u002Fname-mismatch\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M7AWXQ5EV9JCA0WG9Q1WB13Y","missing-metadata","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Ffixtures\u002Fskills\u002Fskills\u002Fmissing-metadata\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M7AWXP8GT7FATM53B914ZN50","malformed-yaml","https:\u002F\u002Fgithub.com\u002Fwxxb789\u002Fmarkturbo\u002Fblob\u002Fmain\u002Ffixtures\u002Fskills\u002Fskills\u002Fmalformed-yaml\u002FSKILL.md",[],[]]