Error handling

From saifoelloh/golang-best-practices-skill · View interactive version

Error handling is an AI agent skill from the GitHub repository saifoelloh/golang-best-practices-skill. Unified Go + GORM + PostgreSQL error handling review. Covers error wrapping, context propagation, PostgreSQL error codes (23505, 40001), errors.Is/As mapping, and retry logic. Ensures proper error chains and robust database failure recovery.

How to use this skill

Skill file

Error Handling (Unified Go & DB)

Expert-level review for error handling in Go services using GORM and PostgreSQL. Ensures errors are correctly identified, preserved via wrapping, mapped to domain errors, and retried where appropriate.

When to Apply

Use this skill when:

Rule Categories

| Priority | Count | Focus |

|---|---|---|

| CRITICAL | 6 | error chains, context leaks, PgError mapping, retries |

| HIGH | 6 | propagation, Is/As usage, RowsAffected, deadlock detection |

| MEDIUM | 2 | sentinel errors, structured logging |

Rules Covered (14 total)

Critical Issues (6)

High-Impact Patterns (6)

Medium Improvements (2)

Trigger Phrases

Output Format

## Critical Issues Found: X

### [Rule ID] (Line Y)
**Issue**: Description
**Impact**: Context leak / Lost chain / Data inconsistency
**Fix**: Suggested code
**Example**:

// Corrected code

Related Skills

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.