diff options
author | Lauris BH <lauris@nix.lv> | 2019-01-30 18:33:00 +0200 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-01-30 11:33:00 -0500 |
commit | fada6968a847f628a6d32ac546e1228838809498 (patch) | |
tree | b0f8c8cd14a5c6e7bbffbc170e52527865a58462 /vendor/code.gitea.io/sdk/gitea/gitea.go | |
parent | 8b5f6ced22d510a399bf304915ad77c61d6ce7b3 (diff) | |
download | gitea-fada6968a847f628a6d32ac546e1228838809498.tar.gz gitea-fada6968a847f628a6d32ac546e1228838809498.zip |
Fix new release creation API to allow empty target (#5870)
* Fix new release creation API to allow empty target
* Add more test cases
* Update swagger
Diffstat (limited to 'vendor/code.gitea.io/sdk/gitea/gitea.go')
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/gitea.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vendor/code.gitea.io/sdk/gitea/gitea.go b/vendor/code.gitea.io/sdk/gitea/gitea.go index 374a3faa96..a5509b2aba 100644 --- a/vendor/code.gitea.io/sdk/gitea/gitea.go +++ b/vendor/code.gitea.io/sdk/gitea/gitea.go @@ -70,6 +70,8 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re return nil, errors.New("403 Forbidden") case 404: return nil, errors.New("404 Not Found") + case 409: + return nil, errors.New("409 Conflict") case 422: return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) } @@ -77,7 +79,9 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re if resp.StatusCode/100 != 2 { errMap := make(map[string]interface{}) if err = json.Unmarshal(data, &errMap); err != nil { - return nil, err + // when the JSON can't be parsed, data was probably empty or a plain string, + // so we try to return a helpful error anyway + return nil, fmt.Errorf("Unknown API Error: %d %s", resp.StatusCode, string(data)) } return nil, errors.New(errMap["message"].(string)) } |