smithery.ai

m06-error-handling

Mastering C++ Error Handling. Triggers: exceptions, try-catch, noexcept, std::expected, std::optional, error codes, assert, terminate.

First seen Mar 30, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,976 B
  • docs SUMMARY.md 160 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 2 installs

SKILL.md

C++ Error Handling

Core Question

Is this error recoverable?

  • Yes (Local): std::expected or return code.
  • Yes (Distant): Exceptions (throw).
  • No (Bug): assert or std::terminate.

Error → Design Question

Issue Design Question
Uncaught Exception Did you forget to catch, or throw in noexcept?
Silent Failure Did you ignore a return code? (Use [[nodiscard]]).
Destructor Throw Never throw from destructor (std::terminate).

Thinking Prompt

  1. Is absence valid?

- Yes? → std::optional<T>.

  1. Does caller need details?

- Yes? → std::expected<T, E> or Exception. - No? → bool or std::optional.

  1. Is it a Logic Error (Bug)?

- Yes? → assert() or std::terminate(). Do not throw for bugs in C++ (Contract Violation).

Trace Up / Down

  • Trace Up:

- Issue: "Program aborted with 'terminate called recursively'." - Cause: An exception was thrown while stack unwinding (in a destructor). - Fix: Fix the destructor. Ensure RAII cleanup is noexcept.

Quick Reference

Mechanism Cost (Happy) Cost (Sad) Use When
std::optional Branch Branch Return may be empty.
std::expected Branch Branch Recoverable error (Parsing).
Exception Zero Huge Rare IO/Resource errors.
Assert Zero (Release) Abort Logic bugs / Invariants.