Skip to content

Commit

Permalink
check HTTP response status code in loadSchema
Browse files Browse the repository at this point in the history
Report an error if it's not 200 OK.
  • Loading branch information
dmitshur committed Oct 6, 2019
1 parent 8cc7547 commit 6d1ea27
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gen.go
Expand Up @@ -71,6 +71,10 @@ func loadSchema(githubToken string) (schema interface{}, err error) {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body)
return nil, fmt.Errorf("non-200 OK status code: %v body: %q", resp.Status, body)
}
err = json.NewDecoder(resp.Body).Decode(&schema)
return schema, err
}
Expand Down

0 comments on commit 6d1ea27

Please sign in to comment.