swift-error-handling
БесплатноБез исполняемых скриптовНе проверенStandards for throwing functions, Result type, and Never. Use when implementing Swift error throwing, designing error hierarchies, using Result types, or…
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
Swift Error Handling
Priority: P0 (CRITICAL)
Workflow: Add Error Handling to Swift Function
- Define custom error enum conforming to
Error - Mark function
throws(orasync throws) - Use
do-catchat call site with specific catch clauses - Map domain errors to user-facing messages at presentation layer
Implementation Guidelines
Throwing Functions
- Propagate Errors: Use
throwsfor recoverable errors andasync throwsfor modern concurrency. - Do-Catch: Handle close to source; specific catch clauses per error type. Catch-all
catch: last resort. - Error Types: Define custom errors as enums conforming to
Error:
See implementation examples for custom error enums, do-catch patterns, and Result type usage.
- Optional Try: Use
try?only for non-critical errors where nil acceptable.
Result Type
- Async Alternatives: Use
throwsfor synchronous code. UseResultfor callbacks and non-async deferred error states. - Transformations: Use
.map(),.flatMap()for functional composition. - Conversion: Use
.get()to convertResultto throwing for use intry-catch.
Never Type & Preconditions
- Fatalisms: Use
Neverreturn type only for unrecoverable crash scenarios or to indicate unreachable code. Never for expected errors. - Preconditions: Use
precondition(),assert(), andfatalError()for programmer errors. UseassertionFailure()for debug-only checks.
Anti-Patterns
- No try!: Use
try?ordo-catch. - No try? without nil check: Handle or log.
- No Error(message): Use typed errors.
References
Установить swift-error-handling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл swift-error-handling?
Standards for throwing functions, Result type, and Never. Use when implementing Swift error throwing, designing error hierarchies, using Result types, or adding do-catch blocks.
Как установить скилл swift-error-handling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл swift-error-handling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic