Skip to content

Commit 69b226e

Browse files
committed
ref(http.go): improve client error message
This PR improves the resultant client error message they get when the returned response is incorrect. This is especially important for determining the error message Old message when using a v2 client with a v1 cluster: ``` http://deis.10.245.1.3.xip.io does not appear to be a valid Deis controller. Make sure that the Controller URI is correct and the server is running. ``` New message: ``` http://deis.10.245.1.3.xip.io/v2/ does not appear to be a valid Deis controller. Make sure that the Controller URI is correct and the server is running. ``` Notice the appended /v2/ path, which users can assume this is a v2 client.
1 parent 6c176d2 commit 69b226e

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

controller/client/http.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ func checkForErrors(res *http.Response, body string) error {
156156
// CheckConnection checks that the user is connected to a network and the URL points to a valid controller.
157157
func CheckConnection(client *http.Client, controllerURL url.URL) error {
158158
errorMessage := `%s does not appear to be a valid Deis controller.
159-
Make sure that the Controller URI is correct and the server is running.`
160-
161-
baseURL := controllerURL.String()
159+
Make sure that the Controller URI is correct, the server is running and
160+
your client version is correct.`
162161

163162
controllerURL.Path = "/v2/"
164163

@@ -172,13 +171,13 @@ Make sure that the Controller URI is correct and the server is running.`
172171
res, err := client.Do(req)
173172

174173
if err != nil {
175-
fmt.Printf(errorMessage+"\n", baseURL)
174+
fmt.Printf(errorMessage+"\n", controllerURL.String())
176175
return err
177176
}
178177
defer res.Body.Close()
179178

180179
if res.StatusCode != 401 {
181-
return fmt.Errorf(errorMessage, baseURL)
180+
return fmt.Errorf(errorMessage, controllerURL.String())
182181
}
183182

184183
checkAPICompatibility(res.Header.Get("DEIS_API_VERSION"))

0 commit comments

Comments
 (0)