-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
37 lines (30 loc) · 765 Bytes
/
Copy patherrors.go
File metadata and controls
37 lines (30 loc) · 765 Bytes
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
package pulse
import "errors"
var (
ErrAgentStopped = errors.New("pulse: agent has been stopped and cannot be started again")
)
// nonRetryableError marks an error as not retryable by export loops.
type nonRetryableError struct {
err error
}
func (e nonRetryableError) Error() string {
if e.err == nil {
return "pulse: non-retryable export error"
}
return e.err.Error()
}
func (e nonRetryableError) Unwrap() error {
return e.err
}
// NonRetryable wraps an error as non-retryable.
func NonRetryable(err error) error {
if err == nil {
return nil
}
return nonRetryableError{err: err}
}
// IsNonRetryable reports whether err is marked as non-retryable.
func IsNonRetryable(err error) bool {
var nre nonRetryableError
return errors.As(err, &nre)
}