jsont error-detail
This commit is contained in:
parent
5eb54fa81b
commit
0325cd9167
3 changed files with 25 additions and 8 deletions
2
src/dune
2
src/dune
|
|
@ -1,7 +1,7 @@
|
||||||
(executable
|
(executable
|
||||||
(public_name mte)
|
(public_name mte)
|
||||||
(name mte)
|
(name mte)
|
||||||
(modules assets assets_crunch headers mte config util)
|
(modules assets assets_crunch headers mte config util types)
|
||||||
(libraries
|
(libraries
|
||||||
headers_lib
|
headers_lib
|
||||||
syntax
|
syntax
|
||||||
|
|
|
||||||
12
src/mte.ml
12
src/mte.ml
|
|
@ -13,13 +13,11 @@
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. *)
|
along with this program. If not, see <https://www.gnu.org/licenses/>. *)
|
||||||
|
|
||||||
(* TODO ??: GANA error codes
|
let error_detail ?hint _status =
|
||||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
let open Types.ErrorDetail in
|
||||||
|
let code = -1 in
|
||||||
(* https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail *)
|
let s = to_string (make code hint) in
|
||||||
let error_detail ?hint status =
|
s
|
||||||
let _ = (hint, status) in
|
|
||||||
"{}"
|
|
||||||
|
|
||||||
module Respond_with = struct
|
module Respond_with = struct
|
||||||
open Vif.Response
|
open Vif.Response
|
||||||
|
|
|
||||||
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