github.com/shiroyuki/docker@v1.9.0/utils/timeout.go (about)

     1  package utils
     2  
     3  import (
     4  	"net"
     5  	"net/url"
     6  )
     7  
     8  // IsTimeout takes an error returned from (generally) the http package and determines if it is a timeout error.
     9  func IsTimeout(err error) bool {
    10  	switch e := err.(type) {
    11  	case net.Error:
    12  		return e.Timeout()
    13  	case *url.Error:
    14  		if t, ok := e.Err.(net.Error); ok {
    15  			return t.Timeout()
    16  		}
    17  		return false
    18  	default:
    19  		return false
    20  	}
    21  }