aboutsummaryrefslogtreecommitdiff
path: root/src/errors/join.go
AgeCommit message (Collapse)Author
2025-12-23Revert "errors: optimize errors.Join for single unwrappable errors"Damien Neil
This reverts CL 635115. Reason for revert: The new behavior does not match the function documentation. Fixes #76961 Change-Id: If2450aa4efba28c7a12887a5b306c231a836e740 Reviewed-on: https://go-review.googlesource.com/c/go/+/731981 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-08-20errors: mention Is/As in Join docsSean Liao
Fixes #74461 Change-Id: Ic1b1b2b43d59dd67f31c2388ca88650ee847ba93 Reviewed-on: https://go-review.googlesource.com/c/go/+/696737 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-07-28errors: omit redundant nil check in type assertion for JoinJes Cok
When ok is true, err can't be nil. Make it behave more like the Unwrap function. Change-Id: Ieba5de57d60f5ff4d6a3468d703e6f72be02a97d GitHub-Last-Rev: 6df9365a1d586bba64df57be11f9ca7b772cc773 GitHub-Pull-Request: golang/go#74764 Reviewed-on: https://go-review.googlesource.com/c/go/+/689920 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Mark Freeman <mark@golang.org> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-04-14errors: optimize errors.Join for single unwrappable errorsdmathieu
Change-Id: I10bbb782ca7234cda8c82353f2255eec5be588c9 GitHub-Last-Rev: e5ad8fdb802e56bb36c41b4982ed27c1e0809af8 GitHub-Pull-Request: golang/go#70770 Reviewed-on: https://go-review.googlesource.com/c/go/+/635115 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-07-31errors: optimize *joinError's Error method for less allocation and faster ↵Jes Cok
execution Handle the case of one error at the beginning. Use unsafe.String to avoid memory allocation when converting byte slice to string. Change-Id: Ib23576f72b1d87489e6f17762be483f62ca4998a GitHub-Last-Rev: ed8003bfbcae8efd42e54895db0554c139b9d3a7 GitHub-Pull-Request: golang/go#60026 Reviewed-on: https://go-review.googlesource.com/c/go/+/493237 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-03-30errors: improve the godoc for Join and UnwrapDaniel Nephin
Document that errors returned by Join always implement Unwrap []error. Explicitly state that Unwrap does not unwrap errors with an Unwrap() []error method. Change-Id: Id610345dcf43ca54a9dde157e56c5815c5112073 GitHub-Last-Rev: 7a0ec450bd0b2b38eecb5b94eaec485f4a6debbd GitHub-Pull-Request: golang/go#59301 Reviewed-on: https://go-review.googlesource.com/c/go/+/480021 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-03-17errors: clarify Join documentationDavid Bendory
The previous documentation used a double-negative in describing Join behavior; this use of language could be confusing. This update removes the double-negative. Change-Id: If13e88682e865314a556e7d381143a97fa5486d9 GitHub-Last-Rev: 92b3f88a5d49229e71adafcfa7b1d01dcb7646f3 GitHub-Pull-Request: golang/go#59082 Reviewed-on: https://go-review.googlesource.com/c/go/+/477095 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-29errors, fmt: add support for wrapping multiple errorsDamien Neil
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>