Swift error handling

From HoangNguyen0403/agent-skills-standard · View interactive version

Swift error handling is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. 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.

How to use this skill

Skill file

Swift Error Handling

**Priority: P0 (CRITICAL)**

Workflow: Add Error Handling to Swift Function

  1. Define custom error enum conforming to Error
  2. Mark function throws (or async throws)
  3. Use do-catch at call site with specific catch clauses
  4. Map domain errors to user-facing messages at presentation layer

Implementation Guidelines

Throwing Functions

See implementation examples for custom error enums, do-catch patterns, and Result type usage.

Result Type

Never Type & Preconditions

Anti-Patterns

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.