Distributed_db: register new internal errors

This commit is contained in:
Benjamin Canou 2017-11-10 09:55:25 +01:00 committed by Grégoire
parent 6cb428c1a2
commit d5a2bd9604

View File

@ -156,7 +156,27 @@ end = struct
Format.fprintf ppf "Missing %s %a" Hash.name Hash.pp key) Format.fprintf ppf "Missing %s %a" Hash.name Hash.pp key)
(Data_encoding.obj1 (Data_encoding.req "key" Hash.encoding)) (Data_encoding.obj1 (Data_encoding.req "key" Hash.encoding))
(function Missing_data key -> Some key | _ -> None) (function Missing_data key -> Some key | _ -> None)
(fun key -> Missing_data key) (fun key -> Missing_data key) ;
register_error_kind
`Permanent
~title: ("Canceled fetch of a " ^ Hash.name)
~description: ("The fetch of a " ^ Hash.name ^ " has been canceled")
~id: ("distributed_db." ^ Hash.name ^ ".fetch_canceled")
~pp: (fun ppf key ->
Format.fprintf ppf "Fetch of %s %a canceled" Hash.name Hash.pp key)
Data_encoding.(obj1 (req "key" Hash.encoding))
(function (Canceled key) -> Some key | _ -> None)
(fun key -> Canceled key) ;
register_error_kind
`Permanent
~title: ("Timed out fetch of a " ^ Hash.name)
~description: ("The fetch of a " ^ Hash.name ^ " has timed out")
~id: ("distributed_db." ^ Hash.name ^ ".fetch_timeout")
~pp: (fun ppf key ->
Format.fprintf ppf "Fetch of %s %a timed out" Hash.name Hash.pp key)
Data_encoding.(obj1 (req "key" Hash.encoding))
(function (Timeout key) -> Some key | _ -> None)
(fun key -> Timeout key)
let read s k = let read s k =
match Memory_table.find s.memory k with match Memory_table.find s.memory k with