errors 0.6.0
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 deprecatedStack() []uintptr
interface, implementations in this package now support aStacktrace
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 rawuintptr
's (representing program counters) providing a type which implement thefmt.Formatter
interface, which in turn exposes various aspect of a call frame (name, source file and line, etc) via thefmt
package. See also #37- The name of the formal parameter to
Wrap
andWrapf
has been renamed fromcause
toerr
. This reflects the nature of these functions; to create a stack of errors. Apparently this also helps editor auto completion. Thanks @matryer. Fixes #32