Error_monad: improve error message for unrecognized errors
This commit is contained in:
parent
77bd0af3d1
commit
4fa11bdf28
@ -413,6 +413,8 @@ module Make() = struct
|
||||
(Format.pp_print_list pp)
|
||||
(List.rev errors)
|
||||
|
||||
|
||||
(** Catch all error when 'serializing' an error. *)
|
||||
type error += Unclassified of string
|
||||
|
||||
let () =
|
||||
@ -439,6 +441,25 @@ module Make() = struct
|
||||
error_kinds :=
|
||||
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
||||
|
||||
(** Catch all error when 'deserializing' an error. *)
|
||||
type error += Unregistred_error of Data_encoding.json
|
||||
|
||||
let () =
|
||||
let id = "" in
|
||||
let category = `Temporary in
|
||||
let to_error msg = Unregistred_error msg in
|
||||
let from_error = function
|
||||
| Unregistred_error json -> Some json
|
||||
| _ -> None in
|
||||
let encoding_case =
|
||||
let open Data_encoding in
|
||||
case Json_only json from_error to_error in
|
||||
let pp ppf json =
|
||||
Format.fprintf ppf "@[<v 2>Unregistred error:@ %a@]"
|
||||
Data_encoding.Json.pp json in
|
||||
error_kinds :=
|
||||
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
||||
|
||||
type error += Assert_error of string * string
|
||||
|
||||
let () =
|
||||
|
Loading…
Reference in New Issue
Block a user