tools: ensure Retriable errors are wrapped only once
This commit is contained in:
parent
89f37f4740
commit
34066887eb
@ -98,10 +98,16 @@ func NewRetriableReader(r io.Reader) io.Reader {
|
||||
|
||||
func (r *RetriableReader) Read(b []byte) (int, error) {
|
||||
n, err := r.reader.Read(b)
|
||||
// EOF is a successful response as it is used to signal a graceful end of input
|
||||
// c.f. https://git.io/v6riQ
|
||||
if err == nil || err == io.EOF {
|
||||
|
||||
// EOF is a successful response as it is used to signal a graceful end
|
||||
// of input c.f. https://git.io/v6riQ
|
||||
//
|
||||
// Otherwise, if the error is non-nill and already retriable (in the
|
||||
// case that the underlying reader `r.reader` is itself a
|
||||
// `*RetriableReader`, return the error wholesale:
|
||||
if err == nil || err == io.EOF || errors.IsRetriableError(err) {
|
||||
return n, err
|
||||
}
|
||||
|
||||
return n, errors.NewRetriableError(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user