File tree Expand file tree Collapse file tree 1 file changed +29
-8
lines changed Expand file tree Collapse file tree 1 file changed +29
-8
lines changed Original file line number Diff line number Diff line change 1818open Rpc
1919open Idl
2020
21+ module D = Debug. Make (struct let name = " v6_interface" end )
22+ open D
23+
2124let service_name = " v6d"
2225let queue_name = ref (Xcp_service. common_prefix ^ service_name)
2326let default_sockets_dir = " /var/lib/xcp"
@@ -91,15 +94,33 @@ type errors =
9194exception V6_error of errors
9295[@@ deriving rpcty]
9396
94- (* * handle exception generation and raising *)
95- let err = Error. {
96- def = errors;
97- raiser = (fun e -> raise (V6_error e));
98- matcher = (function
99- | V6_error e -> Some e
100- | e -> Some (Internal_error (Printexc. to_string e)))
101- }
10297
98+ let () = (* register printer *)
99+ let sprintf = Printf. sprintf in
100+ let string_of_error e =
101+ Rpcmarshal. marshal errors.Rpc.Types. ty e |> Rpc. to_string in
102+ let printer = function
103+ | V6_error e ->
104+ Some (sprintf " V6_interface.V6_error(%s)" (string_of_error e))
105+ | _ -> None in
106+ Printexc. register_printer printer
107+
108+ (* * handle exception generation and raising *)
109+ let err = Error.
110+ { def = errors
111+ ; raiser = (fun e ->
112+ log_backtrace () ;
113+ let exn = V6_error e in
114+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
115+ raise exn )
116+ ; matcher = (function
117+ | V6_error e as exn ->
118+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
119+ Some e
120+ | exn ->
121+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
122+ Some (Internal_error (Printexc. to_string exn )))
123+ }
103124
104125(* * functor to autogenerate code using PPX *)
105126module RPC_API (R : RPC ) = struct
You can’t perform that action at this time.
0 commit comments