jsont error-detail
This commit is contained in:
parent
5eb54fa81b
commit
0325cd9167
3 changed files with 25 additions and 8 deletions
19
src/types.ml
Normal file
19
src/types.ml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(* 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue