File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change 1515open Rpc
1616open Idl
1717
18+ module D = Debug. Make (struct let name = " gpumon_interface" end )
19+ open D
20+
1821let service_name = " gpumon"
1922let queue_name = Xcp_service. common_prefix ^ service_name
2023let xml_path = " /var/xapi/" ^ service_name
@@ -73,14 +76,32 @@ type gpu_errors =
7376
7477exception Gpumon_error of gpu_errors
7578
79+ let () = (* register printer *)
80+ let sprintf = Printf. sprintf in
81+ let string_of_error e =
82+ Rpcmarshal. marshal gpu_errors.Rpc.Types. ty e |> Rpc. to_string in
83+ let printer = function
84+ | Gpumon_error e ->
85+ Some (sprintf " Gpumon_interface.Gpumon_error(%s)" (string_of_error e))
86+ | _ -> None in
87+ Printexc. register_printer printer
88+
7689(* * Error handler *)
77- let gpu_err = Error. {
78- def = gpu_errors;
79- raiser = (fun e -> raise (Gpumon_error e));
80- matcher = (function
81- | Gpumon_error e -> Some e
82- | e -> Some (Internal_error (Printexc. to_string e)))
83- }
90+ let gpu_err = Error.
91+ { def = gpu_errors
92+ ; raiser = (fun e ->
93+ log_backtrace () ;
94+ let exn = Gpumon_error e in
95+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
96+ raise exn )
97+ ; matcher = (function
98+ | Gpumon_error e as exn ->
99+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
100+ Some e
101+ | exn ->
102+ error " %s (%s)" (Printexc. to_string exn ) __LOC__;
103+ Some (Internal_error (Printexc. to_string exn )))
104+ }
84105
85106(* * Functor to autogenerate API calls *)
86107module RPC_API (R : RPC ) = struct
You can’t perform that action at this time.
0 commit comments