Make sure wrapped retry/fatal errors are never nil to avoid panic

This commit is contained in:
Nick Craig-Wood 2016-12-13 16:02:14 +00:00
parent ec0916c59d
commit 8083804575

View file

@ -58,6 +58,9 @@ var _ Retrier = wrappedRetryError{(error)(nil)}
// RetryError makes an error which indicates it would like to be retried
func RetryError(err error) error {
if err == nil {
err = errors.New("needs retry")
}
return wrappedRetryError{err}
}
@ -100,6 +103,9 @@ var _ Fataler = wrappedFatalError{(error)(nil)}
// FatalError makes an error which indicates it is a fatal error and
// the sync should stop.
func FatalError(err error) error {
if err == nil {
err = errors.New("fatal error")
}
return wrappedFatalError{err}
}