go/src/fmt
Damien Neil 4a0a2b33df errors, fmt: add support for wrapping multiple errors
An error which implements an "Unwrap() []error" method wraps all the
non-nil errors in the returned []error.

We replace the concept of the "error chain" inspected by errors.Is
and errors.As with the "error tree". Is and As perform a pre-order,
depth-first traversal of an error's tree. As returns the first
matching result, if any.

The new errors.Join function returns an error wrapping a list of errors.

The fmt.Errorf function now supports multiple instances of the %w verb.

For #53435.

Change-Id: Ib7402e70b68e28af8f201d2b66bd8e87ccfb5283
Reviewed-on: https://go-review.googlesource.com/c/go/+/432898
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-09-29 18:40:40 +00:00
..
doc.go all: gofmt main repo 2022-04-11 16:34:30 +00:00
errors.go errors, fmt: add support for wrapping multiple errors 2022-09-29 18:40:40 +00:00
errors_test.go errors, fmt: add support for wrapping multiple errors 2022-09-29 18:40:40 +00:00
example_test.go fmt: fix spelling mistake in example 2019-03-25 21:03:10 +00:00
export_test.go fmt: add tests for parsenum 2016-10-04 21:00:35 +00:00
fmt_test.go fmt: rely on utf8.AppendRune 2022-09-21 13:54:31 +00:00
format.go fmt: rely on utf8.AppendRune 2022-09-21 13:54:31 +00:00
gostringer_example_test.go fmt: add example for GoStringer interface 2018-09-06 04:25:17 +00:00
print.go errors, fmt: add support for wrapping multiple errors 2022-09-29 18:40:40 +00:00
scan.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
scan_test.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
state_test.go fmt: add a function to recover the original format string given a State 2022-08-06 09:19:31 +00:00
stringer_example_test.go fmt: add an example for Errorf 2018-08-30 19:40:13 +00:00
stringer_test.go