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.Fprintfwill be removed in the 0.7 release. Read on for more details.- The
Locationinterface,
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
Stackinterface,
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
Stacktraceinterface. As a replacement for the deprecatedStack() []uintptrinterface, implementations in this package now support aStacktraceinterface
type Stacktrace interface {
Stacktrace() []Frame
}Calling this method returns a slice of Frame values, the most recent on the top. See #37
Framevalues replace rawuintptr's (representing program counters) providing a type which implement thefmt.Formatterinterface, which in turn exposes various aspect of a call frame (name, source file and line, etc) via thefmtpackage. See also #37- The name of the formal parameter to
WrapandWrapfhas been renamed fromcausetoerr. This reflects the nature of these functions; to create a stack of errors. Apparently this also helps editor auto completion. Thanks @matryer. Fixes #32