Go has many things out of the box. But most of the time, they are not enough.

Errors is a very good example.

The go pattern is to concatenate error

var prefix = "dialer"
if err!= nil {
    return fmt.Errorf("%s: something failed: %v", prefix, err)
}

That that become unwieldy fast, especially when it goes through several layers of libraries. Evident by multierror and Wrap.

Even at improbable, we have our own errors library. The approach we’ve taken follows several main points:

  1. Error has a code and message, similar to grpc errors.
  2. Codes follows grpc codes
  3. Errors are chainable. Think of it as vertically stacking errors.
  4. Combo errors can be used to concurrently add errors in go routines

Wrapping semantics

Change code and message Change only message Rethrow error To gRPC

Formatting

FatalWithErr for cli Details Desc

Walking through errors