Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmdutil: Support errors.Join-based multi-errors
cmdutil has some special handling for hashicorp/go-multierror so that multi-errors are printed cleanly in the form: %d errors occurred: 1) foo 2) bar ... In Go 1.20, the errors package got a native `errors.Join` function. This adds support for errors.Join-based multi-errors to this logic. These errors implement an `Unwrap() []error` method which can be used to access the full list of errors. We use that and then implement the same logic for formatting as before.
- Loading branch information
Showing
3 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
changelog/pending/20230829--sdk-go--support-multi-errors-built-from-errors-join.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- type: chore | ||
scope: sdk/go | ||
description: Support multi-errors built from errors.Join for RunFunc, Exit, and friends. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters