Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Note that fmt.Errorf is not preferred

...

  • Return the original error if there is no additional context to add and you want to maintain the original error type.
  • Add context using errors.Wrap so that the error message provides more context and errors.Unwrap can be used to extract the original error. Prefer this to fmt.Errorf("some message %w").
  • Use errors.Newf if the callers do not need to detect or handle that specific error case.
  • Use errors.Handle or errors.NewAssertionErrorWithWrappedErrf to hide the original cause.

...