Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

kinbiko/rogerr

Open more actions menu

Repository files navigation

rogerr

Build Status Coverage Status Go Report Card Latest version Go Documentation License

A Go package for error handling with structured metadata. Zero dependencies.

Blog post with detailed explanation.

Problem

Error messages that include unique data (user IDs, timestamps, etc.) break error grouping in monitoring tools like Sentry and Rollbar.

Solution

Store unique data as structured metadata separate from the error message. This package attaches metadata to Go's context.Context and preserves it when wrapping errors.

Usage

  1. Create an ErrorHandler: handler := rogerr.NewErrorHandler()
  2. Add metadata to context: ctx = rogerr.WithMetadatum(ctx, "userID", 123)
  3. Wrap errors with metadata: err = handler.Wrap(ctx, err, "operation failed")
  4. Extract metadata for logging: metadata := rogerr.Metadata(err)

Build Options

For cleaner stacktraces, use the -trimpath flag:

go build -trimpath ./cmd/myapp

This shows module-relative paths instead of absolute paths. Skip this if you disable stacktraces with rogerr.WithStacktrace(false).

Full documentation

Releases

Used by

Contributors

Languages

Generated from kinbiko/go-template
Morty Proxy This is a proxified and sanitized view of the page, visit original site.