MCPcopy Index your code
hub / github.com/cloudfoundry/cli / WrapNetworkErrors

Function WrapNetworkErrors

cf/net/http_client.go:77–105  ·  view source on GitHub ↗
(host string, err error)

Source from the content-addressed store, hash-verified

75}
76
77func WrapNetworkErrors(host string, err error) error {
78 var innerErr error
79 switch typedErr := err.(type) {
80 case *url.Error:
81 innerErr = typedErr.Err
82 case *websocket.DialError:
83 innerErr = typedErr.Err
84 }
85
86 if innerErr != nil {
87 if asErrors.As(innerErr, &x509.UnknownAuthorityError{}) {
88 return errors.NewInvalidSSLCert(host, T("unknown authority"))
89 }
90 if asErrors.As(innerErr, &x509.HostnameError{}) {
91 return errors.NewInvalidSSLCert(host, T("not valid for the requested host"))
92 }
93 if asErrors.As(innerErr, &x509.CertificateInvalidError{}) {
94 return errors.NewInvalidSSLCert(host, "")
95 }
96 typedInnerErr := new(net.OpError)
97 if asErrors.As(innerErr, &typedInnerErr) {
98 if typedInnerErr.Op == "dial" {
99 return fmt.Errorf("%s: %s\n%s", T("Error performing request"), err.Error(), T("TIP: If you are behind a firewall and require an HTTP proxy, verify the https_proxy environment variable is correctly set. Else, check your network connection."))
100 }
101 }
102 }
103
104 return fmt.Errorf("%s: %s", T("Error performing request"), err.Error())
105}
106
107func getBaseDomain(host string) string {
108 hostURL, _ := url.Parse(host)

Callers 2

Calls 2

NewInvalidSSLCertFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected