Make IsRetryError function

This commit is contained in:
Nick Craig-Wood 2016-05-14 17:11:19 +01:00
parent 2db35f0ce7
commit ac9c20b048
2 changed files with 10 additions and 1 deletions

View file

@ -58,6 +58,15 @@ func RetryError(err error) error {
return plainRetryError{err} return plainRetryError{err}
} }
// IsRetryError returns true if err conforms to the Retry interface
// and calling the Retry method returns true.
func IsRetryError(err error) bool {
if r, ok := err.(Retry); ok {
return r.Retry()
}
return false
}
// isClosedConnError reports whether err is an error from use of a closed // isClosedConnError reports whether err is an error from use of a closed
// network connection. // network connection.
// //

View file

@ -238,7 +238,7 @@ tryAgain:
inErr = in.Close() inErr = in.Close()
} }
// Retry if err returned a retry error // Retry if err returned a retry error
if r, ok := err.(Retry); ok && r.Retry() && tries < maxTries { if IsRetryError(err) && tries < maxTries {
tries++ tries++
Log(src, "Received error: %v - low level retry %d/%d", err, tries, maxTries) Log(src, "Received error: %v - low level retry %d/%d", err, tries, maxTries)
if removeFailedCopy(dst) { if removeFailedCopy(dst) {