From: Jonathan Amsterdam Date: Mon, 5 Aug 2019 14:14:40 +0000 (-0400) Subject: doc/go1.13.html: describe error-value additions X-Git-Tag: go1.13rc1~34 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a4c825156d0a3817377a2b7e5b30ab50e11440ab;p=gostls13.git doc/go1.13.html: describe error-value additions A brief description at the top the Standard Library section of the changes to support error wrapping. Fixes #33365. Change-Id: Id5a3b2fe148d9bfb949f2cfc9e5d8a1613a0e219 Reviewed-on: https://go-review.googlesource.com/c/go/+/188798 Reviewed-by: Ian Lance Taylor --- diff --git a/doc/go1.13.html b/doc/go1.13.html index bc44531133..f38474b327 100644 --- a/doc/go1.13.html +++ b/doc/go1.13.html @@ -525,6 +525,37 @@ godoc crypto/ed25519 when used with Go 1.13+.

+

Error wrapping

+ +

+ Go 1.13 contains support for error wrapping, as first proposed in + the + Error Values proposal and discussed on the + associated issue. +

+

+ An error e can wrap another error w by providing + an Unwrap method that returns w. Both e + and w are available to programs, allowing e to provide + additional context to w or to reinterpret it while still allowing + programs to make decisions based on w. +

+

+ To support wrapping, fmt.Errorf now has a %w + verb for creating wrapped errors, and three new functions in + the errors package ( + errors.Unwrap, + errors.Is and + errors.As) simplify unwrapping + and inspecting wrapped errors. +

+

+ For more information, read the errors package + documentation, or see + the Error Value FAQ. + There will soon be a blog post as well. +

+

Minor changes to the library

@@ -612,7 +643,8 @@ godoc

- The new function As finds the first error in a given error’s chain + The new function As finds the first + error in a given error’s chain (sequence of wrapped errors) that matches a given target’s type, and if so, sets the target to that error value.