nim-error-handling
Design clear Nim error-handling flows; when to raise exceptions vs return `Option`/`bool`, how to enforce non-raising contracts, and where to translate or…
Skill by Vyrnexis
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/vyrnexis-nim-error-handling
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nim-error-handling
What's inside
- Skill name
nim-error-handling- Description
- Design clear Nim error-handling flows; when to raise exceptions vs return `Option`/`bool`, how to enforce non-raising contracts, and where to translate or record failures. Use when reviewing failure behavior, exception boundaries, recovery, or batch processing that needs per-item error reporting.
- License
- MIT
- Instructions
- 71 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- batch_preview_boundary.md · references/
SKILL.md (first lines)
# Nim Error Handling
## Rules
### Choose the Failure Channel
- Return `bool` when success or failure is the whole result.
- Return `Option[T]` when success returns a value but absence is expected.
- Use `bool` with a `var` parameter only when filling or mutating caller-owned storage is part of the API.
- Convert per-item failures into structured outcomes at the batch boundary. Keep intermediate steps exception-based.
### Add Only Real Failure Paths
- Read what the current operation promises and how each called API reports failure.
- If a successful call guarantees valid output, do not add another raising nil, size, or range check.
- If a condition breaks no documented promise, remove the raising check and document the valid behavior.
- Report failure when the result cannot safely satisfy its API or the operation cannot meet its documented promise.
- If an operation requires a stronger guarantee than the API it calls, validate that guarantee in that operation.
### Place Boundaries
- Let failures propagate through intermediate steps.
- Catch only where the handler can recover, translate, or record the failure.
- At a batch boundary, record recoverable per-item failures.
### Choose Exception Types
- For a contract failure caused by caller input or the environment, raise the closest existing `CatchableError`.
- Separate `except` branches when handling differs. Group exception types when handling is identical.
- Put child exception types before their parents in `except` branches.
- Catch `CatchableError` only when the boundary handles every recoverable error. Do not catch bare `Exception`.
- Add a custom exception only when callers handle it differently. Derive it from the closest existing `CatchableError` subtype.
- Do not use `Defect` for recoverable failures; it represents a programming bug and is not caught by `CatchableError`.
- Use `assert` for conditions whose failure means a programming bug: preconditions, internal invariants, and state guards,
as in `assert s.opened, "next called before open"`.
- Do not use range conversions for recoverable validation, e.g. `Positive(parseInt(s))`; invalid values raise `RangeDefect`.
### Translate and Inspect Errors
- Translate errors only at module or subsystem boundaries. Add local context and preserve the original reason.
- If the handler only needs the message text, use `getCurrentExceptionMsg()`.
- If the handler needs exception fields, use `except X as e`.
### Cleanup and Contracts
- Use `try/finally` for cleanup.
- Use `{.raises: [].}` when a proc must not raise. Leave raising procs unannotated.
## Workflow
1. **Read the contracts.** Note what this operation promises, how called APIs report failure, and what they guarantee on success.
2. **Decide whether failure is needed.** Name the documented promise that the condition would break. If there is none, remove the check.
3. **Place the decision.** Document valid behavior as success, or report failure in the first operation whose promise is broken.
4. **Place catch boundaries.** Catch only where the handler can recover, translate, or record the failure.
5. **Enforce non-raising contracts.** Add `{.raises: [].}` only to procs that must not raise.
## Common Mistakes
| Mistake | Why it is wrong |
|---------|-----------------|
| Parent `except` before child | First-match dispatch makes the child handler unreachable. |
| Catching bare `Exception` | Also catches `Defect` and can hide programming bugs. |
| Rechecking guaranteed output | Adds dead branches and can contradict the lower-level API. |
| Rejecting allowed behavior | Silently narrows the operation's contract. |
## References
- `references/batch_preview_boundary.md` — Per-item batch failures with reporting failures allowed
to escape.From Vyrnexis/nim-agent-template, MIT.
More from Vyrnexis/nim-agent-template
- 0.574score
nim-ownership-hooks
Vyrnexis
Implement and review Nim ARC/ORC ownership hooks for types that manually manage resources, including move-only, deep-copy, refcounted, and copy-on-write…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
atlas-package-cloner
Vyrnexis
Use Atlas to initialize Nim projects, install or update Atlas-managed dependencies, configure dependency directories, inspect Atlas-generated nim.cfg paths…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nimonyplugins
Vyrnexis
Build and debug Nimony compile-time plugins for code generation and DSL rewrites.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-style-guide
Vyrnexis
Write clear, consistent Nim code in a simple stdlib-aligned style, covering imports, naming, proc vs func vs template choices, local variables, constructors…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-api-design
Vyrnexis
Design clear public Nim APIs for libraries and modules, including exported types, constructors, parameter ownership, lookup functions, error contracts, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-bindings
Vyrnexis
Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-wrappers
Vyrnexis
Turn low-level C FFI bindings into an idiomatic Nim API, with safer types, cleaner module boundaries, resource management, callbacks, enums, bitflags, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-code-organization
Vyrnexis
Organize Nim modules and multi-step workflows with explicit state ownership, cohesive boundaries, narrow exports, and structured orchestration.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-debugging
Vyrnexis
Debug Nim compile failures, crashes, wrong results, macro expansion, ownership behavior, and unsafe-memory defects using focused reproduction, stack traces…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-testing
Vyrnexis
Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-doc-comments
Vyrnexis
Document exported Nim modules and APIs with doc comments that `nim doc` actually picks up, including module docs, proc and type docs, field docs, and runnable…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-fuzzing
Vyrnexis
Set up and run libFuzzer-based fuzz targets for Nim code, including harness wiring, compilation flags, corpus management, structure-aware mutators, and crash…
SkillBFreshness: B★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 2
- Open issues
- 0
- Last commit (this folder)
- Aug 20, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Vyrnexis/nim-agent-template
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Vyrnexis
- 0.574score
nim-c-wrappers
Vyrnexis
Turn low-level C FFI bindings into an idiomatic Nim API, with safer types, cleaner module boundaries, resource management, callbacks, enums, bitflags, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-testing
Vyrnexis
Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
atlas-package-cloner
Vyrnexis
Use Atlas to initialize Nim projects, install or update Atlas-managed dependencies, configure dependency directories, inspect Atlas-generated nim.cfg paths…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-api-design
Vyrnexis
Design clear public Nim APIs for libraries and modules, including exported types, constructors, parameter ownership, lookup functions, error contracts, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-bindings
Vyrnexis
Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-code-organization
Vyrnexis
Organize Nim modules and multi-step workflows with explicit state ownership, cohesive boundaries, narrow exports, and structured orchestration.
SkillBFreshness: B★ 4Claude Code +9
Cite this page
nim-error-handling skill. Agent Mart. https://agentmart.dev/skills/vyrnexis-nim-error-handling (last updated 2026-10-24)