We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57ca10b commit ee57ac1Copy full SHA for ee57ac1
src/repo/learnocaml_process_common.ml
@@ -15,5 +15,17 @@ let to_file encoding fn value =
15
let from_file encoding fn =
16
Lwt_io.(with_file ~mode: Input) fn @@ fun chan ->
17
Lwt_io.read chan >>= fun str ->
18
- let json = Ezjsonm.from_string str in
+ let json =
19
+ match Ezjsonm.from_string_result str with
20
+ | Ok json -> json
21
+ | Error err ->
22
+ let loc = match Ezjsonm.read_error_location err with
23
+ | None -> fn
24
+ | Some ((li, col), _) ->
25
+ Printf.sprintf "%s, line %d, column %d" fn li col
26
+ in
27
+ Printf.ksprintf failwith
28
+ "Parse error in %s:\n %s" loc
29
+ (Ezjsonm.read_error_description err);
30
31
Lwt.return (Json_encoding.destruct encoding json)
0 commit comments