cmd/syncthing: Improve "cli debug file" handling

Proper URL encoding, and return a sensible error when it's not found.
This commit is contained in:
Jakob Borg
2021-06-05 11:19:02 +02:00
parent 6494a9332d
commit 0e9d2a13af
3 changed files with 11 additions and 2 deletions
+3 -1
View File
@@ -134,9 +134,11 @@ func (c *apiClient) Post(url, body string) (*http.Response, error) {
return c.Do(request)
}
var errNotFound = errors.New("invalid endpoint or API call")
func checkResponse(response *http.Response) error {
if response.StatusCode == http.StatusNotFound {
return errors.New("invalid endpoint or API call")
return errNotFound
} else if response.StatusCode == http.StatusUnauthorized {
return errors.New("invalid API key")
} else if response.StatusCode != http.StatusOK {