aboutsummaryrefslogtreecommitdiff
path: root/lib/http.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/http.ml')
-rw-r--r--lib/http.ml7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/http.ml b/lib/http.ml
index abc2b28..e2e5471 100644
--- a/lib/http.ml
+++ b/lib/http.ml
@@ -34,7 +34,12 @@ module Make(T : S.Token) = struct
| Some r -> Mvar.put (Rl.find_exn !rl path) r
| None -> raise Bad_response_headers)
>>= fun () ->
- body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string
+ match resp |> Response.status |> Code.code_of_status with
+ | 200 -> body |> Cohttp_async.Body.to_string >>= Deferred.Or_error.return
+ | code ->
+ body |> Cohttp_async.Body.to_string >>= fun body ->
+ Deferred.Or_error.errorf "Unsuccessful response received: %d - %s" code body
+
let request ?(body=`Null) m path =
rl := Rl.update ~f:(function