parseBoolResponse determines the boolean result from a GitHub API response. Several GitHub API methods return boolean responses indicated by the HTTP status code in the response (true indicated by a 204, false indicated by a 404). This helper function will determine that result and hide the 404 erro
(err error)
| 1792 | // 404). This helper function will determine that result and hide the 404 |
| 1793 | // error if present. Any other error will be returned through as-is. |
| 1794 | func parseBoolResponse(err error) (bool, error) { |
| 1795 | if err == nil { |
| 1796 | return true, nil |
| 1797 | } |
| 1798 | |
| 1799 | var rerr *ErrorResponse |
| 1800 | if errors.As(err, &rerr) && rerr.Response.StatusCode == http.StatusNotFound { |
| 1801 | // Simply false. In this one case, we do not pass the error through. |
| 1802 | return false, nil |
| 1803 | } |
| 1804 | |
| 1805 | // some other real error occurred |
| 1806 | return false, err |
| 1807 | } |
| 1808 | |
| 1809 | // RateLimitCategory represents the enumeration of rate limit categories. |
| 1810 | type RateLimitCategory uint8 |
no outgoing calls
searching dependent graphs…