error-handling

Provides Error-handling for HTTP API endpoints via typed exceptions and centralized handlers.

1|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/pdylanross/barnacle --skill error-handling-pdylanross
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/pdylanross/barnacle/tree/main/.claude/skills/error-handling
Command: npx skills add https://github.com/pdylanross/barnacle --skill error-handling-pdylanross

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces best practices for error handling in Go, preventing common pitfalls and making code more robust and maintainable.

Core Features & Use Cases

  • Standardized Error Definitions: Uses global error variables for consistent error checking.
  • Error Wrapping: Preserves error chains using fmt.Errorf("%w", ...) for better debugging.
  • HTTP API Error Factories: Leverages httptk for OCI-compliant HTTP error responses.
  • Use Case: Ensure all API endpoints return errors that are easily distinguishable by clients using errors.Is() and errors.As(), and that underlying causes are preserved.

Quick Start

Apply the error-handling skill to ensure all function returns use global error variables and wrap underlying errors with %w.

Frequently Asked Questions about error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I preserve error context in Go using error wrapping?

Error wrapping in Go preserves the underlying cause by using `fmt.Errorf` with the `%w` verb. This maintains the error chain, allowing callers to inspect root causes via `errors.Is` and `errors.As` while adding debugging context.

What is the best way to define standard Go errors for HTTP APIs?

Standard Go errors for HTTP APIs are defined using global error variables and generated via the `httptk` package. This ensures API endpoints return OCI-compliant responses that clients can easily distinguish using standard error checking functions.

Why use global error variables for Go error handling?

Global error variables provide a standardized reference for consistent error checking across Go applications. They allow functions to return specific sentinel errors that callers can reliably compare against using `errors.Is` to determine exact failure modes.

How do I generate OCI-compliant HTTP error responses in Go?

OCI-compliant HTTP error responses are generated using the `httptk` package to standardize API failures. This enforces consistent error generation patterns that conform to OCI specifications for easily distinguishable client-side error handling.

Can I use `errors.Is` and `errors.As` with wrapped Go errors?

Yes, `errors.Is` and `errors.As` work seamlessly with wrapped Go errors. Wrapping errors with `fmt.Errorf` using `%w` preserves the error chain, allowing these functions to traverse the wrapped errors and match specific types or sentinel values.

Does this approach handle both standard Go errors and HTTP API errors?

Yes, this approach handles both standard Go errors and HTTP API errors by enforcing global error variables and wrapping with `%w` for general robustness, while utilizing `httptk` factories specifically for OCI-compliant HTTP API error generation.