Client: minor error printing tweaks

This commit is contained in:
Benjamin Canou 2018-05-23 23:26:47 +02:00 committed by Grégoire Henry
parent 51cfa388f8
commit fe435ce114
2 changed files with 6 additions and 4 deletions

View File

@ -143,10 +143,12 @@ let main select_commands =
Format.eprintf "@{<error>@{<title>Fatal error@}@} unknown protocol version.@." ; Format.eprintf "@{<error>@{<title>Fatal error@}@} unknown protocol version.@." ;
Lwt.return 1 Lwt.return 1
| Failure message -> | Failure message ->
Format.eprintf "@{<error>@{<title>Fatal error@}@} %s.@." message ; Format.eprintf "@{<error>@{<title>Fatal error@}@} @[<hov 0>%a@]@."
Format.pp_print_text message ;
Lwt.return 1 Lwt.return 1
| exn -> | exn ->
Format.printf "@{<error>@{<title>Fatal error@}@} %s.@." (Printexc.to_string exn) ; Format.printf "@{<error>@{<title>Fatal error@}@} @[<hov 0>%a@]@."
Format.pp_print_text (Printexc.to_string exn) ;
Lwt.return 1 Lwt.return 1
end >>= fun retcode -> end >>= fun retcode ->
Format.pp_print_flush Format.err_formatter () ; Format.pp_print_flush Format.err_formatter () ;

View File

@ -124,7 +124,7 @@ module Make(Prefix : sig val id : string end) = struct
(req "kind" (constant "generic")) (req "kind" (constant "generic"))
(req "error" string))) (req "error" string)))
from_error to_error in from_error to_error in
let pp = Format.pp_print_string in let pp ppf s = Format.fprintf ppf "@[<h 0>%a@]" Format.pp_print_text s in
error_kinds := error_kinds :=
Error_kind { id ; title ; description ; Error_kind { id ; title ; description ;
from_error ; category ; encoding_case ; pp } :: !error_kinds from_error ; category ; encoding_case ; pp } :: !error_kinds
@ -603,7 +603,7 @@ let () =
~id:"failure" ~id:"failure"
~title:"Generic error" ~title:"Generic error"
~description:"Unclassified error" ~description:"Unclassified error"
~pp:Format.pp_print_string ~pp:(fun ppf s -> Format.fprintf ppf "@[<h 0>%a@]" Format.pp_print_text s)
Data_encoding.(obj1 (req "msg" string)) Data_encoding.(obj1 (req "msg" string))
(function (function
| Exn (Failure msg) -> Some msg | Exn (Failure msg) -> Some msg