-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy patherrors.go
More file actions
40 lines (33 loc) · 1.04 KB
/
errors.go
File metadata and controls
40 lines (33 loc) · 1.04 KB
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
36
37
38
39
40
package network
import (
"errors"
"fmt"
)
var (
EmptyTargetList = errors.New("target list empty")
)
// TransientError represents an error returned from a network layer function call
// which may be interpreted as non-critical. In general, we desire that all expected
// error return values are enumerated in a function's documentation - any undocumented
// errors are considered fatal. However, 3rd party libraries don't always conform to
// this standard, including the networking libraries we use. This error type can be
// used to wrap these 3rd party errors on the boundary into flow-go, to explicitly
// mark them as non-critical.
type TransientError struct {
Err error
}
func (err TransientError) Error() string {
return err.Err.Error()
}
func (err TransientError) Unwrap() error {
return err.Err
}
func NewTransientErrorf(msg string, args ...interface{}) TransientError {
return TransientError{
Err: fmt.Errorf(msg, args...),
}
}
func IsTransientError(err error) bool {
var errTransient TransientError
return errors.As(err, &errTransient)
}