Skip to content
Permalink
Browse files

check HTTP response status code in loadSchema

Report an error if it's not 200 OK.
  • Loading branch information...
dmitshur committed Oct 6, 2019
1 parent 8cc7547 commit 6d1ea27df5210159a4fb51d926b09feffed1bc77
Showing with 4 additions and 0 deletions.
  1. +4 −0 gen.go
4 gen.go
@@ -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
}

0 comments on commit 6d1ea27

Please sign in to comment.
You can’t perform that action at this time.