From a288c2b3a3d867a1c25d5627357bfc16e7b083fe Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 9 Sep 2015 23:22:41 +0100 Subject: [PATCH] Make a retry error wrapper for a plain error --- fs/fs.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/fs.go b/fs/fs.go index 8e8cbe065..c213a522b 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -222,6 +222,24 @@ func RetryErrorf(format string, a ...interface{}) error { return retryError(fmt.Sprintf(format, a...)) } +// PlainRetryError is an error wrapped so it will retry +type plainRetryError struct { + error +} + +// Retry interface +func (_ plainRetryError) Retry() bool { + return true +} + +// Check interface +var _ Retry = plainRetryError{(error)(nil)} + +// RetryError makes an error which indicates it would like to be retried +func RetryError(err error) error { + return plainRetryError{err} +} + // A channel of Objects type ObjectsChan chan Object