Error Handling

21 projects

Go treats errors as values, and the standard library now covers the core patterns: fmt.Errorf with %w wraps errors, errors.Is and errors.As inspect chains, and since Go 1.20 errors.Join and multiple %w verbs combine several errors into one. The libraries listed here add what the standard errors lack: stack traces, structured context for logging, error codes and classification, and safe transport across process boundaries.

cockroachdb/errors is a full-featured replacement that adds stack traces, hints, encoding errors over the network, and redaction of sensitive details. rotisserie/eris and joomcode/errorx also add stack traces and wrapping utilities, and ztrue/tracerr prints source fragments around each frame. samber/oops attaches structured attributes such as user or request IDs that log well with slog. Southclaws/fault takes a decorator approach to wrapping. hashicorp/go-multierror and uber-go/multierr combine errors and remain common in older code, though errors.Join now covers the basic case. The archived pkg/errors, once the standard for stack traces, is not listed here.

For most code, the standard errors package with %w wrapping and sentinel or typed errors is enough. Add a library when you need stack traces in production logs, consistent error codes across an API, or structured context that your logging pipeline can index. Avoid mixing several error libraries in one codebase, since their wrapping conventions can conflict.

go-multierrorby hashicorp

Go (golang) package for representing a list of errors as a single error.

github.com/hashicorp/go-multierrorGo 1.13+ No dependencies updated 19d ago

2.6k

errorsby cockroachdb

Go error library with error portability over the network.

github.com/cockroachdb/errorsGo 1.25+ 13 dependenciesv1.14.0updated 14d ago

2.5k

erisby rotisserie

A better way to handle, trace, and log errors in Go. Compatible with the standard error library and github.com/pkg/errors.

github.com/rotisserie/erisGo 1.18+ No dependencies updated 1y ago

1.8k

errorxby joomcode

A feature rich error package with stack traces, composition of errors and more.

github.com/joomcode/errorxGo 1.11+ 1 dependencyv1.2.0updated 1y ago

1.3k

multierrby uber-go

Package for representing a list of errors as a single error.

go.uber.org/multierrGo 1.20+ 1 dependencyv1.11.0updated 2y ago

1.2k

tracerrby ztrue

Golang errors with stack trace and source fragments.

github.com/ztrue/tracerrNo dependencies updated 7mo ago

1.1k

oopsby samber

Error handling with context, stack trace and source fragments.

github.com/samber/oopsGo 1.21+ 5 dependenciesv1.23.2updated 1d ago

995

errlogby snwfdhmp

Hackable package that determines responsible source code for an error (and some other fast-debugging features). Pluggable to any logger in-place.

updated 3y ago

458

emperror

Error handling tools and best practices for Go libraries and applications.

emperror.dev/emperrorGo 1.12+ 1 dependencyv0.30.0updated 6y ago

391

Faultby Southclaws

An ergonomic mechanism for wrapping errors in order to facilitate structured metadata and context for error values.

github.com/Southclaws/faultGo 1.18+ 4 dependenciesv0.8.2updated 1y ago

307

errorsby emperror

Drop-in replacement for the standard library errors package and github.com/pkg/errors. Provides various error handling primitives.

emperror.dev/errorsGo 1.12+ 2 dependenciesupdated 4y ago

203

errorsby naughtygopher

Drop-in replacement for builtin Go errors. This is a minimal error handling package with custom error types, user friendly messages, Unwrap & Is. With very easy to use and straightforward helper functions.

github.com/naughtygopher/errorsGo 1.23+ 1 dependencyv1.3.1updated 1y ago

76

exceptionby rbrahul

A simple utility package for exception handling with try-catch in Golang.

github.com/rbrahul/exceptionGo 1.16+ No dependencies updated 3y ago

38

Falconby SonicRoshan

A Simple Yet Highly Powerful Package For Error Handling.

updated 7y ago

11

errorsby PumpkinSeed

The most simple error wrapper with awesome performance and minimal memory overhead.

github.com/PumpkinSeed/errorsGo 1.13+ No dependencies updated 4y ago

7

errorsby neuronlabs

Simple golang error handling with classification primitives.

github.com/neuronlabs/errorsGo 1.12+ 2 dependenciesv1.2.0updated 7y ago

6

metaerrby quantumcycle

A library to create your custom error builders producing structured errors with metadata from different sources and optional stacktraces.

github.com/quantumcycle/metaerrGo 1.21+ 1 dependencyv1.2.0updated 4mo ago

6

go-bruhby aisbergg

Error handling with stack traces, custom formatting, and observability integration.

github.com/aisbergg/go-bruhGo 1.25+ 1 dependencyv1.3.0updated 7d ago

3

go-errr

Error handling library with Catch/Recover semantics, wrapped error chains, and stack traces for Go.

github.com/go-errr/goGo 1.24+ 1 dependencyv1.0.17updated 17d ago

2

ctxerrorsby psyb0t

Wrap errors with the file, line, and function name of each call site.

github.com/psyb0t/ctxerrorsGo 1.26+ 1 dependencyv0.9.0updated 3d ago

1
e

errors

Providing errors with a stack trace and optional structured details. Compatible with github.com/pkg/errors API but does not use it internally.

gitlab.com

Esc

Type to search every entry. ↑↓ to move, Enter to open.