-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
35 lines (29 loc) · 981 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package errors
import (
"errors"
"fmt"
)
// New returns an error that formats as the given text.
func New(text string) error {
return errors.New(text) //nolint: goerr113
}
// Errorf formats according to a format specifier and returns the string
// as a value that satisfies error.
func Errorf(format string, args ...any) error {
return fmt.Errorf(format, args...) //nolint: goerr113
}
// Unwrap returns the result of calling the Unwrap method on err, if err's
// type contains an Unwrap method returning error.
// Otherwise, Unwrap returns nil.
func Unwrap(err error) error {
return errors.Unwrap(err)
}
// Is reports whether any error in err's tree matches target.
func Is(err, target error) bool {
return errors.Is(err, target)
}
// As finds the first error in err's tree that matches target, and if one is found, sets
// target to that error value and returns true. Otherwise, it returns false.
func As(err error, target any) bool {
return errors.As(err, target)
}