19 lines
684 B
OCaml
19 lines
684 B
OCaml
(* https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail *)
|
|
module ErrorDetail = struct
|
|
(* TODO GANA error codes
|
|
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
|
type t = { code: int; hint: string option }
|
|
|
|
let make code hint = { code; hint }
|
|
let enc_code v = v.code
|
|
let enc_hint v = v.hint
|
|
|
|
let jsont =
|
|
Jsont.Object.map ~kind:"ErrorDetail" make
|
|
|> Jsont.Object.mem "code" Jsont.int ~enc:enc_code
|
|
|> Jsont.Object.opt_mem "hint" Jsont.(string) ~enc:enc_hint
|
|
|> Jsont.Object.finish
|
|
|
|
let to_string v = Jsont_bytesrw.encode_string jsont v |> Result.get_ok
|
|
let of_string v = Jsont_bytesrw.decode_string jsont v
|
|
end
|