golang-samber-oops

Enrich Go errors with domain, codes, context, and stack traces.

Updated Apr 24, 2026
One-click install
npx skills add https://github.com/Utchash007/TermTales --skill golang-samber-oops-utchash007
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-oops
Source: https://github.com/Utchash007/TermTales/tree/main/.agents/skills/golang-samber-oops
Command: npx skills add https://github.com/Utchash007/TermTales --skill golang-samber-oops-utchash007

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go's standard error handling lacks context, making debugging and observability challenging; samber/oops adds structured context, stack traces, error codes, and safe public messages to errors so on-call engineers can diagnose issues quickly.

Core Features & Use Cases

  • Fluent builder pattern for constructing rich errors: In, Tags, Code, User, Tenant, With, Public, Wrap, Recover.
  • Structured attributes and codes enable better aggregation in logs and APM.
  • Context propagation across layers (HTTP handlers, services, repositories) using WithBuilder and FromContext to preserve full trace.

Quick Start

Create a structured error by chaining In, Code, User, With, and Public, then Wrap or Recover as needed.

Frequently Asked Questions about golang-samber-oops

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

FAQPage Schema
How do I add context and stack traces to Go errors for better observability?

Structured error handling in Go enriches errors with domain, codes, context, and stack traces. Using a fluent builder pattern allows you to chain methods like In, Code, and With to preserve full error context for quick diagnosis.

What is the best way to propagate structured errors across HTTP handlers and service layers in Go?

Propagating structured errors across service layers utilizes context propagation. By using WithBuilder and FromContext, you can preserve the full error trace and structured attributes from HTTP handlers down to repositories.

How do I build safe public error messages in Go without exposing internal stack traces?

Building safe public error messages involves using the Public method within a fluent builder pattern. This separates safe user-facing messages from internal structured context, stack traces, and error codes used for observability.

Can I aggregate Go error codes and attributes in APM and logging systems?

Yes, structured error handling assigns specific error codes and attributes to errors. These structured fields enable better aggregation and analysis of application issues directly within logs and APM platforms.

How do I recover from a panic and convert it into a structured error in Go?

To recover from panics and convert them into structured errors, use the Recover method provided by the fluent builder pattern. This captures the panic, attaches stack traces and context, and wraps it safely for observability.