errors v0.6.0 Release Notes

Release Date: 2016-06-07 // almost 8 years ago
  • 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