From 0489f9e4e096654f966ecdd67cee3eb5eba6e3d7 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Sun, 4 Feb 2018 01:30:41 +0000 Subject: [PATCH] fixes #88 to handle 422 better (#89) lets return an error if a 422 occurs and return the error message to the caller in case there is missing or invalid data in the request --- gitea/gitea.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitea/gitea.go b/gitea/gitea.go index 20cb44f..374a3fa 100644 --- a/gitea/gitea.go +++ b/gitea/gitea.go @@ -7,6 +7,7 @@ package gitea import ( "encoding/json" "errors" + "fmt" "io" "io/ioutil" "net/http" @@ -69,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 422: + return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) } if resp.StatusCode/100 != 2 {