Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 0489f9e

Browse files
jstrachanlunny
authored andcommitted
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
1 parent a184f2d commit 0489f9e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

gitea/gitea.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package gitea
77
import (
88
"encoding/json"
99
"errors"
10+
"fmt"
1011
"io"
1112
"io/ioutil"
1213
"net/http"
@@ -69,6 +70,8 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re
6970
return nil, errors.New("403 Forbidden")
7071
case 404:
7172
return nil, errors.New("404 Not Found")
73+
case 422:
74+
return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data))
7275
}
7376

7477
if resp.StatusCode/100 != 2 {

0 commit comments

Comments
 (0)