Commits

camlspotter committed 4016be3

using Xjson.Error

Comments (0)

Files changed (3)

   type t = 
     | Hg  (:"hg":) 
     | Git (:"git":) 
-  with conv(json), conv(ocaml)
+  with conv(json, ocaml)
 end
 
 module LocalTime = struct
   (* CRv2 jfuruse: this should be lazily parsed date *)
-  type t = string with conv(json), conv(ocaml)
+  type t = string with conv(json, ocaml)
 end
 
 module UTCTime = struct
   (* CRv2 jfuruse: this should be lazily parsed date *)
-  type t = string with conv(json), conv(ocaml)
-end
-
-(* CR jfuruse: can be shared with other json apps *)
-module Error = struct
-  open Format
-
-  let wrap_json_conv convf s = match convf s with
-    | `Ok v -> `Ok v
-    | `Error e -> `Error (`Json_conv e)
-
-  let format ppf = function
-    | `Http (n, _err) -> fprintf ppf "HTTP Error %d@." n
-    | `Json_parse exn -> fprintf ppf "Error at Json parse: %s@." (Printexc.to_string exn)
-    | `Other exn      -> fprintf ppf "Error: %s@." (Printexc.to_string exn)
-    | `Json_conv e    -> Json_conv.format_full_error Format.err_formatter e
+  type t = string with conv(json, ocaml)
 end
 
 module Data = struct
       fork_of           : t option;
       mq_of             : t option;
       creator           : string option;
-    > with conv(json), conv(ocaml)
+    > with conv(json, ocaml)
   end
 
   (** Commited file *)  
     type t = <
       type_ as "type" : string;
       file : string;
-    > with conv(json), conv(ocaml)
+    > with conv(json, ocaml)
   end
 
   (** Branch info *)    
       parents      : string list;
       branch       : string;
       unknown      : Json.t mc_leftovers;
-    > with conv(json), conv(ocaml)
+    > with conv(json, ocaml)
 
   end
 
       avatar       : string;
       resource_uri : string;
       user_rest    : Json.t mc_leftovers;
-    > with conv(json), conv(ocaml)
+    > with conv(json, ocaml)
   end
 
   module User = struct
       user : UserID.t;
       repositories : Repository.t list;
       rest : Json.t mc_leftovers;
-    > with conv(json), conv(ocaml)
+    > with conv(json, ocaml)
   end
 
   module UserRepo = struct
   (* https://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/branches *)
   module Branches = struct
 
-    type t = Data.Branch.t mc_fields with conv(json), conv(ocaml)
+    type t = Data.Branch.t mc_fields with conv(json, ocaml)
 
     let get ~accountname ~repo_slug = 
       Format.eprintf "%s : %s...@." accountname repo_slug;
 open Meta_conv.Result.Open
 open Tiny_json
 
-(* CR jfuruse: can be shared with other json apps *)
 let ocaml_of_t : Json.t Ocaml_conv.encoder = fun j -> Ocaml.String (Json.show j)
 let t_of_ocaml : Json.t Ocaml_conv.decoder = fun ?(trace=[]) o ->
   try match o with
 
 let parse s = try `Ok (Json.parse s) with e -> `Error (`Json_parse e)
 
-(* CR jfuruse: can be shared with other json apps *)
 module Error = struct
   open Format
 
        | `Json_parse of exn
        | `Other of exn ] 
     -> unit
+
   val from_Ok :
     [< `Error of [< `Http of int * 'a
                  | `Json_conv of Json.t Meta_conv.Error.t