Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

errors 0.6.0

Compare
Choose a tag to compare
@davecheney davecheney released this 07 Jun 07:58
· 95 commits to master since this release

What's new since version 0.5.1

The 0.6.0 release is a transitional release aimed at exposing the error's call stack, introduced in 0.5.0, to the caller.

0.6.0 is the last release that will support the errors.Fprint helper function. This function will be removed in version 0.7 and will be replaced with a more flexible option based on the fmt.Formatter interface.

Many thanks to @ChrisHines for inspiration, via his go-stack/stack package, and for his thoughtful review feedback.

Deprecation notice

The following symbols have been deprecated and will be removed in future releases.

  • errors.Fprintf will be removed in the 0.7 release. Read on for more details.
  • The Location interface,
type location interface {
        Location() (string, int)
}

is deprecated and will not be recognised in future releases. The replacement is

fmt.Sprintf("%+v", err.Stacktrace()[0])

That is, pass the topmost element of error's stack trace (assuming it has a Stacktrace() []Frame method) to fmt and print it with the %+v verb.

  • The Stack interface,
type stack interface {
        Stack() []uintptr
}

is deprecated and will not be recognised in future releases. Callers should use the new Stacktrace interface described below.

New features

  • Stacktrace interface. As a replacement for the deprecated Stack() []uintptr interface, implementations in this package now support a Stacktrace interface
type Stacktrace interface {
         Stacktrace() []Frame
}

Calling this method returns a slice of Frame values, the most recent on the top. See #37

  • Frame values replace raw uintptr's (representing program counters) providing a type which implement the fmt.Formatter interface, which in turn exposes various aspect of a call frame (name, source file and line, etc) via the fmt package. See also #37
  • The name of the formal parameter to Wrap and Wrapf has been renamed from cause to err. This reflects the nature of these functions; to create a stack of errors. Apparently this also helps editor auto completion. Thanks @matryer. Fixes #32