How to handle rate-limits?
djui opened this issue · comments
When an error occurs like rate-limit exceeded, the response is unparsed (safe-parse not applied?), thus it's not clear that an error occur from the client side, because keys like :status
or :trace-redirects
or :body
could be part of a valid response. Maybe the response should be a nil
or an exception should be thrown (which I like much less). Then the client can check for nil and do the api-meta
call to see what went wrong.
Btw, the api-meta
seems not to work for me. I guess it's because the metadata gets lost after the call and assigning it to a variable. But is necessary for inspection and decision, e.g.
(defn succeeded? [meta]
(and meta (not= (403 (:status meta)))))
(let [res (repos/languages "Raynes" "tentacles")]
(when (succeeded? (core/api-meta res)))
res)
;=> nil
Looking into this. There are some other issues with the metadata stuff as it is.
With the new 0.2.6 api-meta
works. (Might have worked before, I just copied that function into my code, then always got nil
). Now I get metadata and understand, that there is only metadata available, if then call succeeded.