I've changed all error wrapping in two production codebases from this: if err != nil { return errors.Wrap(err, "failed to do a thing") } And this: if err != nil { return fmt.Errorf("failed to do a thing: %w", err) } And (ugh... yes this existed somewhere) this:
Wrapping errors in Go: A new approach
Wrapping errors in Go: A new approach
Wrapping errors in Go: A new approach
I've changed all error wrapping in two production codebases from this: if err != nil { return errors.Wrap(err, "failed to do a thing") } And this: if err != nil { return fmt.Errorf("failed to do a thing: %w", err) } And (ugh... yes this existed somewhere) this: