Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Add err msg for invalid target
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanyfay committed Mar 2, 2016
1 parent feb4c53 commit 08d96ac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mgmt/rest/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (c *Client) do(method, path string, ct contentType, body ...[]byte) (*rbody
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
return nil, fmt.Errorf("error connecting to API URI: %s. Do you have an http/https mismatch?", c.URL)
}
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
case "PUT":
var b *bytes.Reader
Expand All @@ -142,14 +142,14 @@ func (c *Client) do(method, path string, ct contentType, body ...[]byte) (*rbody
req, err := http.NewRequest("PUT", c.prefix+path, b)
req.Header.Add("Content-Type", ct.String())
if err != nil {
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
rsp, err = c.http.Do(req)
if err != nil {
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
return nil, fmt.Errorf("error connecting to API URI: %s. Do you have an http/https mismatch?", c.URL)
}
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
case "DELETE":
var b *bytes.Reader
Expand All @@ -161,14 +161,14 @@ func (c *Client) do(method, path string, ct contentType, body ...[]byte) (*rbody
req, err := http.NewRequest("DELETE", c.prefix+path, b)
req.Header.Add("Content-Type", "application/json")
if err != nil {
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
rsp, err = c.http.Do(req)
if err != nil {
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
return nil, fmt.Errorf("error connecting to API URI: %s. Do you have an http/https mismatch?", c.URL)
}
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
case "POST":
var b *bytes.Reader
Expand All @@ -182,7 +182,7 @@ func (c *Client) do(method, path string, ct contentType, body ...[]byte) (*rbody
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
return nil, fmt.Errorf("error connecting to API URI: %s. Do you have an http/https mismatch?", c.URL)
}
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@ func (c *Client) pluginUploadRequest(pluginPaths []string) (*rbody.APIResponse,

req, err := http.NewRequest("POST", c.prefix+"/plugins", pr)
if err != nil {
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}

req.Header.Add("Content-Type", writer.FormDataContentType())
Expand All @@ -261,7 +261,7 @@ func (c *Client) pluginUploadRequest(pluginPaths []string) (*rbody.APIResponse,
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
return nil, fmt.Errorf("error connecting to API URI: %s. Do you have an http/https mismatch?", c.URL)
}
return nil, err
return nil, fmt.Errorf("URL target is not available. %v", err)
}
cErr := <-errChan
if cErr != nil {
Expand Down

0 comments on commit 08d96ac

Please sign in to comment.