1009 handle binary error responses

closes #1009 
Thanks for the review... I like your suggestions. I had forgotten about
multimethods in Clojure(context switching has its costs sometimes).

Will implement the changes as suggested.


On Thu, Nov 20, 2014 at 8:33 PM, Peter Lubell-Doughtie <
notifications@github.com> wrote:

> In src/clj/ona/api/io.clj:
>
> > @@ -71,8 +73,11 @@
> >    ([method url account options filename use-raw-response?]
> >       (let [options+auth (add-auth-to-options account options)
> >             {:keys [status body]} (http-request method url options+auth)]
> > -       (if (and filename (< status 400))
> > -         (parse-binary-response body filename)
> > -         (if use-raw-response?
> > -           {:body body :status status}
> > -           (parse-json-response body))))))
> > +       (if (>= status 400)
>
> We/I was vague about this when we talked today, but I do not like the idea
> of varying the format of the response based on the status, then the client
> (of this function) does not know what to expect. This would be a bigger
> change (because everything that calls this method would need to be updated)
> but I would prefer something like:
>
> (let [response (if (and filename (< status 400)) (parse-binary-response body filename)
>                    (if use-raw-response? body (parse-json-response body)]
>   {:response response :status status}
>
> I've change body in the map to response since that's more accurate if it
> may be a parsed version.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/onaio/zebra/pull/1022/files#r20662598>.
>