We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9316aeb commit 0548e8cCopy full SHA for 0548e8c
group.go
@@ -6,6 +6,15 @@ type ErrorGroup interface {
6
Errors() []error
7
}
8
9
+// Errors uses the ErrorGroup interface to return a slice of errors.
10
+// If the ErrorGroup interface is not implemented it returns an array containing just the given error.
11
+func Errors(err error) []error {
12
+ if eg, ok := err.(ErrorGroup); ok {
13
+ return eg.Errors()
14
+ }
15
+ return []error{err}
16
+}
17
+
18
// WalkDeep does a depth-first traversal of all errors.
19
// Any ErrorGroup is traversed (after going deep).
20
// The visitor function can return true to end the traversal early
0 commit comments