1
+ //go:build go1.13
1
2
// +build go1.13
2
3
3
4
package errors
@@ -6,14 +7,17 @@ import (
6
7
baseErrors "errors"
7
8
)
8
9
9
- // find error in any wrapped error
10
+ // As finds the first error in err's tree that matches target, and if one is found, sets
11
+ // target to that error value and returns true. Otherwise, it returns false.
12
+ //
13
+ // For more information see stdlib errors.As.
10
14
func As (err error , target interface {}) bool {
11
15
return baseErrors .As (err , target )
12
16
}
13
17
14
18
// Is detects whether the error is equal to a given error. Errors
15
19
// are considered equal by this function if they are matched by errors.Is
16
- // or if their contained errors are matched through errors.Is
20
+ // or if their contained errors are matched through errors.Is.
17
21
func Is (e error , original error ) bool {
18
22
if baseErrors .Is (e , original ) {
19
23
return true
@@ -29,3 +33,29 @@ func Is(e error, original error) bool {
29
33
30
34
return false
31
35
}
36
+
37
+ // Join returns an error that wraps the given errors.
38
+ // Any nil error values are discarded.
39
+ // Join returns nil if every value in errs is nil.
40
+ // The error formats as the concatenation of the strings obtained
41
+ // by calling the Error method of each element of errs, with a newline
42
+ // between each string.
43
+ //
44
+ // A non-nil error returned by Join implements the Unwrap() []error method.
45
+ //
46
+ // For more information see stdlib errors.Join.
47
+ func Join (errs ... error ) error {
48
+ return baseErrors .Join (errs ... )
49
+ }
50
+
51
+ // Unwrap returns the result of calling the Unwrap method on err, if err's
52
+ // type contains an Unwrap method returning error.
53
+ // Otherwise, Unwrap returns nil.
54
+ //
55
+ // Unwrap only calls a method of the form "Unwrap() error".
56
+ // In particular Unwrap does not unwrap errors returned by [Join].
57
+ //
58
+ // For more information see stdlib errors.Unwrap.
59
+ func Unwrap (err error ) error {
60
+ return baseErrors .Unwrap (err )
61
+ }
0 commit comments