Commit 932efea

Richard Luby <richluby@gmail.com>
2016-11-17 06:37:35
fixed client crash if server not up
1 parent 457a368
Changed files (1)
command.go
@@ -157,10 +157,10 @@ func displayTest(clientTest ClientTest) {
 // from the server
 func getScoreFromServer(command Command) error {
 	resp, err := client.Get(clientConfig.SERVER_URL + API_ROOT + "/test/score?username=" + clientConfig.USER)
-	defer resp.Body.Close()
 	if err != nil {
 		return fmt.Errorf("Error while making request: %+v", err)
 	}
+	defer resp.Body.Close()
 	clientTests := []ClientTest{}
 	decoder := json.NewDecoder(resp.Body)
 	err = decoder.Decode(&clientTests)