Client: better error messages for unwrapped JSON objects.

This commit is contained in:
Pietro 2018-03-05 14:18:01 +01:00 committed by Grégoire Henry
parent 55ad294595
commit 01dd7d152a

View File

@ -395,6 +395,10 @@ let call raw_url (cctxt : #Client_context.full) =
let call_with_json raw_url json (cctxt: #Client_context.full) = let call_with_json raw_url json (cctxt: #Client_context.full) =
let uri = Uri.of_string raw_url in let uri = Uri.of_string raw_url in
match Data_encoding.Json.from_string json with match Data_encoding.Json.from_string json with
| exception Assert_failure _ ->
(* Ref : https://github.com/mirage/ezjsonm/issues/31 *)
cctxt#error
"Failed to parse the provided json: unwrapped JSON value.\n%!"
| Error err -> | Error err ->
cctxt#error cctxt#error
"Failed to parse the provided json: %s\n%!" "Failed to parse the provided json: %s\n%!"