+ better ErrorDetail
This commit is contained in:
parent
28d69de95a
commit
153ee78260
2 changed files with 74 additions and 20 deletions
91
src/api.ml
91
src/api.ml
|
|
@ -59,25 +59,6 @@ module Account_operation = struct
|
|||
|> Jsont.enum ~kind:"account operation type"
|
||||
end
|
||||
|
||||
(* TODO error response
|
||||
- use GANA error codes
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
module ErrorDetail = struct
|
||||
type t = {
|
||||
code: int;
|
||||
hint: string option;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make code hint = { code; hint } in
|
||||
let enc_code v = v.code in
|
||||
let enc_hint v = v.hint in
|
||||
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
|
||||
end
|
||||
|
||||
module B32 = struct
|
||||
include B32
|
||||
|
||||
|
|
@ -129,6 +110,78 @@ module RelativeTime = struct
|
|||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
(* TODO error response
|
||||
- use GANA error codes
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
module ErrorDetail = struct
|
||||
type t = {
|
||||
code: int;
|
||||
hint: string option;
|
||||
detail: string option;
|
||||
parameter: string option;
|
||||
path: string option;
|
||||
offset: string option;
|
||||
index: string option;
|
||||
object_: string option;
|
||||
currency: string option;
|
||||
type_expected: string option;
|
||||
type_actual: string option;
|
||||
extra: Jsont.json option;
|
||||
}
|
||||
|
||||
let make code hint detail parameter path offset index object_ currency
|
||||
type_expected type_actual extra =
|
||||
{
|
||||
code;
|
||||
hint;
|
||||
detail;
|
||||
parameter;
|
||||
path;
|
||||
offset;
|
||||
index;
|
||||
object_;
|
||||
currency;
|
||||
type_expected;
|
||||
type_actual;
|
||||
extra;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let code v = v.code in
|
||||
let hint v = v.hint in
|
||||
let detail v = v.detail in
|
||||
let parameter v = v.parameter in
|
||||
let path v = v.path in
|
||||
let offset v = v.offset in
|
||||
let index v = v.index in
|
||||
let object_ v = v.object_ in
|
||||
let currency v = v.currency in
|
||||
let type_expected v = v.type_expected in
|
||||
let type_actual v = v.type_actual in
|
||||
let extra v = v.extra in
|
||||
|
||||
let open Jsont.Object in
|
||||
map ~kind:"ErrorDetail" make
|
||||
|> mem "code" Jsont.int ~enc:code
|
||||
|> opt_mem "hint" Jsont.string ~enc:hint
|
||||
|> opt_mem "detail" Jsont.string ~enc:detail
|
||||
|> opt_mem "parameter" Jsont.string ~enc:parameter
|
||||
|> opt_mem "path" Jsont.string ~enc:path
|
||||
|> opt_mem "offset" Jsont.string ~enc:offset
|
||||
|> opt_mem "index" Jsont.string ~enc:index
|
||||
|> opt_mem "object" Jsont.string ~enc:object_
|
||||
|> opt_mem "currency" Jsont.string ~enc:currency
|
||||
|> opt_mem "type_expected" Jsont.string ~enc:type_expected
|
||||
|> opt_mem "type_actual" Jsont.string ~enc:type_actual
|
||||
|> opt_mem "extra" (Jsont.any ()) ~enc:extra
|
||||
|> finish
|
||||
|
||||
let make ?hint ?detail ?parameter ?path ?offset ?index ?object_ ?currency
|
||||
?type_expected ?type_actual ?extra code =
|
||||
make code hint detail parameter path offset index object_ currency
|
||||
type_expected type_actual extra
|
||||
end
|
||||
|
||||
module CurrencySpecification = struct
|
||||
type t = {
|
||||
name: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue