don't be clever with server errors

This commit is contained in:
Andre Medeiros 2021-09-25 14:42:53 -04:00
parent b9e6950cb1
commit 203b6600d5

View file

@ -123,17 +123,8 @@ func (rac *AuthenticatedClient) request(r *Request, rh ResponseHandler, empty in
if resp.StatusCode != 200 {
_ = rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
// Try to parse a json error. Otherwise we generate a generic one
parser := rac.pool.Get()
defer rac.pool.Put(parser)
val, jerr := parser.ParseBytes(bb)
if jerr != nil {
return nil, ServerError{resp.StatusCode}
}
return nil, NewError(val, resp.StatusCode)
}
if r.emptyResponseBytes > 0 && len(bb) == r.emptyResponseBytes {
return empty, nil