patternsresult-type | Skill Performance & Reviews | TopRankSkills

TopRank Skills

Home / Skills / tools / patternsresult-type

patternsresult-type

maintained by mgreenly

star 1 account_tree 0 verified_user MIT License
bolt View GitHub

name: patterns/result-type description: Result Type Pattern (C-Specific) pattern for C development

Result Type Pattern (C-Specific)

Return struct containing success/failure status plus value or error. Explicit error handling without exceptions. Caller must check result.

ikigai Application

Core type: res_t used throughout:

res_t result = ik_cfg_load(ctx, path, &cfg);
if (!result.ok) {
    // Handle error, result.error contains message
}

Macros:

  • OK(value) - Construct success result
  • ERR(msg) - Construct error result
  • TRY(expr) - Propagate error if failed
  • CHECK(cond, msg) - Return error if condition false

Benefits:

  • Errors can't be ignored (must check .ok)
  • Error context propagates up call stack
  • No hidden control flow (unlike exceptions)

See: project/error_handling.md for patterns.

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!

Skill Details

GitHub Stars 1
GitHub Forks 0
Created Jan 2026
Last Updated 5 months ago
tools tools ide plugins

Related Skills

writing-skills
chevron_right
codex
chevron_right
smart-illustrator
chevron_right
ast-index
chevron_right
packmind-standard-creator
chevron_right

Build your own?

Join 12,000+ developers contributing to the Claude ecosystem.