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
This commit is contained in:
parent
a184f2d334
commit
0489f9e4e0
1 changed files with 3 additions and 0 deletions
|
@ -7,6 +7,7 @@ package gitea
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"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")
|
return nil, errors.New("403 Forbidden")
|
||||||
case 404:
|
case 404:
|
||||||
return nil, errors.New("404 Not Found")
|
return nil, errors.New("404 Not Found")
|
||||||
|
case 422:
|
||||||
|
return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode/100 != 2 {
|
if resp.StatusCode/100 != 2 {
|
||||||
|
|
Loading…
Reference in a new issue