diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-29 17:18:49 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-29 17:18:49 -0700 |
| commit | 2e76d2a6763260401c4ad168f3eb4f8416573fce (patch) | |
| tree | 5061bf3c65f11dfb8e6b55772f10f99ee0dbd2bf /lib/http.ml | |
| parent | Remove some silly internals (diff) | |
| download | disml-2e76d2a6763260401c4ad168f3eb4f8416573fce.tar.xz disml-2e76d2a6763260401c4ad168f3eb4f8416573fce.zip | |
Better shard shutdown and HTTP error logging
Diffstat (limited to 'lib/http.ml')
| -rw-r--r-- | lib/http.ml | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/http.ml b/lib/http.ml index 5e49843..283ab69 100644 --- a/lib/http.ml +++ b/lib/http.ml @@ -33,9 +33,11 @@ module Base = struct | None -> return ())
>>= fun () ->
match resp |> Response.status |> Code.code_of_status with
- | 200 -> body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string >>= Deferred.Or_error.return
+ | code when Code.is_success code -> body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string >>= Deferred.Or_error.return
| code ->
body |> Cohttp_async.Body.to_string >>= fun body ->
+ let headers = Response.sexp_of_t resp |> Sexp.to_string_hum in
+ Logs.warn (fun m -> m "[Unsuccessful Response] [Code: %d]\n%s\n%s" code body headers);
Deferred.Or_error.errorf "Unsuccessful response received: %d - %s" code body
let request ?(body=`Null) ?(query=[]) m path =
|