Error interface wrappers for Google's errdetails protobuf types, because they're handy as heck and I want to use them more

Error Detail wrappers

This project provides wrappers around googleapis/rpc/errdetails types, as well as an error type wrapping gRPC status codes.

An error created or wrapped by this package can be unwrapped and transcribed to a Status message type with all the added details intact.

Until inspiration strikes again, all the errors contained herein are derivative of Google's errdetails messages.

Consider unwrapping these errors to enrich logs as well, they're genuinely useful constructs for everyday purposes.

Why, though?

Story time.

We never utilized the WithDetails functionality of gRPC Status messages, or even *status.Status at all, preferring instead to use regular old errors with a translation layer in middleware.

There's so much more knowledge you can express in a Status response coming right from your API layer though, and I wished for some way to make the Status message and arbitrary details more palatable to a team already familiar with error wrapping.

At the same time, I wanted a unified error response body from all our JSON API's, even the ones not transcoded from gRPC.

If only I could just, wrap a Status message with Details like an error.

And if only I could write my wrapped error right through a middleware layer to turn it into JSON.

Fast forward.

Until recently, I was struggling to understand when I should use an interface type in Go. I understood what, and mostly why, but the intuition wasn't all here.

While working on localizations for a project, it started to click a bit. Inspiration hit when I wanted to combine localizability with errors, and maybe also a request ID, and wouldn't ya know it suddenly I couldn't sleep with all the notes I had to write to myself in the "Probably Ideas" category, because errdetails is a thing that exists.

So to reinforce and practice the point till intuition, and also to get it out of the head so I can sleep again, I popped this old idea off the ol' // TODO: list and got to writing something I'll probably never maintain or use, but maybe I will and it'll be nice.

Owner
Claudia Hardman
Staff Software Engineer at @Mattel
Claudia Hardman
Similar Resources

A flexible error support library for Go

errors Please see http://godoc.org/github.com/spacemonkeygo/errors for info License Copyright (C) 2014 Space Monkey, Inc. Licensed under the Apache Li

Nov 3, 2022

A powerful, custom error package for Go

custom-error-go A powerful, custom error package for Go Detailed explanation: https://medium.com/codealchemist/error-handling-in-go-made-more-powerful

Apr 19, 2022

Declarative error handling for Go.

ErrorFlow Declarative error handling for Go. Motivation Reading list: Don't defer Close() on writable files Error Handling — Problem Overview Proposal

Mar 3, 2022

Go extract error codes

go-extract-error-codes Overview This library helps to extract possible error codes from configured go-restful applications quality level: PoC High Lev

Nov 24, 2021

brief: a piece of error handling codelet

brief a piece of error handling codelet. this code only demonstrates how to hide sql.ErrNoRows to the caller. the Get() method defined in the pkg/proj

Oct 30, 2021

Just another error handling primitives for golang

errors Just another error handling primitives for golang Install go install github.com/WAY29/errors@latest Usage New error and print error context Th

Feb 19, 2022

ApolloError compliant error function for gqlgen

gqlgen-apollo-error ApolloError compliant error function for gqlgen Installation $ go get -u github.com/s-ichikawa/gqlgen-apollo-error Quickstart Retu

Sep 6, 2022

Golang advanced error usage with stack tracing

UhOh Golang advanced error usage with stack tracing uhoh consists of 3 parts: Original error Description of error Stack trace File Function Line Usage

Mar 30, 2022

🥷 CError (Custom Error Handling)

🥷 CError (Custom Error Handling) Installation Via go packages: go get github.com/rozturac/cerror Usage Here is a sample CError uses: import ( "gi

Sep 21, 2022
Go error library with error portability over the network

cockroachdb/errors: Go errors with network portability This library aims to be used as a drop-in replacement to github.com/pkg/errors and Go's standar

Dec 29, 2022
A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.
A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.

Errors Errors package is a drop-in replacement of the built-in Go errors package with no external dependencies. It lets you create errors of 11 differ

Dec 6, 2022
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.

Errlog: reduce debugging time while programming Introduction Use errlog to improve error logging and speed up debugging while you create amazing code

Nov 18, 2022
Error tracing and annotation.

errors -- import "github.com/juju/errgo" The errors package provides a way to create and diagnose errors. It is compatible with the usual Go error idi

Nov 3, 2022
Generic error handling with panic, recover, and defer.

Generic error handling with panic, recover, and defer.

Aug 25, 2022
Simple, intuitive and effective error handling for Go

Error Handling with eluv-io/errors-go The package eluv-io/errors-go makes Go error handling simple, intuitive and effective. err := someFunctionThatCa

Jan 19, 2022
This structured Error package wraps errors with context and other info

RErr package This structured Error package wraps errors with context and other info. It can be used to enrich logging, for example with a structured l

Jan 21, 2022
Simple error handling primitives

errors Package errors provides simple error handling primitives. go get github.com/pkg/errors The traditional error handling idiom in Go is roughly ak

Dec 26, 2022
A comprehensive error handling library for Go

Highlights The errorx library provides error implementation and error-related utilities. Library features include (but are not limited to): Stack trac

Jan 6, 2023
A Go (golang) package for representing a list of errors as a single error.

go-multierror go-multierror is a package for Go that provides a mechanism for representing a list of error values as a single error. This allows a fun

Jan 1, 2023