From 3a149af66716d3f4c1a69ecbd7fc3b333d20536d Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Fri, 20 Jan 2017 13:13:42 +0100 Subject: [PATCH] Utils: include error id in the default error pretty printer. --- src/utils/error_monad.ml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/error_monad.ml b/src/utils/error_monad.ml index 8ff3375ae..b434eef4f 100644 --- a/src/utils/error_monad.ml +++ b/src/utils/error_monad.ml @@ -16,10 +16,12 @@ type error_category = [ `Branch | `Temporary | `Permanent ] type 'err full_error_category = [ error_category | `Wrapped of 'err -> error_category ] -let json_pp encoding ppf x = +let json_pp id encoding ppf x = + let encoding = + Data_encoding.(merge_objs (obj1 (req "id" string)) encoding) in Format.pp_print_string ppf @@ Data_encoding_ezjsonm.to_string @@ - Data_encoding.Json.(construct encoding x) + Data_encoding.Json.(construct encoding (id, x)) module Make() = struct @@ -74,7 +76,7 @@ module Make() = struct category ; from_error ; encoding_case ; - pp = Utils.unopt (json_pp encoding) pp } :: !error_kinds + pp = Utils.unopt (json_pp name encoding) pp } :: !error_kinds let register_wrapped_error_kind category ~id ~title ~description ?pp