2019-05-13 00:46:25 +04:00
|
|
|
include Simple_utils.Trace
|
|
|
|
|
|
|
|
module AE = Memory_proto_alpha.Alpha_environment
|
|
|
|
module TP = Tezos_base__TzPervasives
|
|
|
|
|
2020-06-12 15:33:14 +04:00
|
|
|
type tezos_alpha_error = [`Tezos_alpha_error of TP.error]
|
|
|
|
|
|
|
|
let of_tz_error (err:X_error_monad.error) : tezos_alpha_error =
|
|
|
|
`Tezos_alpha_error err
|
2019-05-13 00:46:25 +04:00
|
|
|
|
|
|
|
let of_alpha_tz_error err = of_tz_error (AE.Ecoproto_error err)
|
|
|
|
|
2020-06-12 15:33:14 +04:00
|
|
|
let trace_alpha_tzresult :
|
|
|
|
(tezos_alpha_error list -> 'b) -> 'a AE.Error_monad.tzresult -> ('a, 'b) result =
|
|
|
|
fun tracer err -> match err with
|
2019-12-10 22:00:21 +04:00
|
|
|
| Ok x -> ok x
|
2020-06-12 15:33:14 +04:00
|
|
|
| Error errs ->
|
|
|
|
fail @@ tracer (List.map of_alpha_tz_error errs)
|
2019-05-13 00:46:25 +04:00
|
|
|
|
2020-06-12 15:33:14 +04:00
|
|
|
let trace_alpha_tzresult_lwt tracer (x:_ AE.Error_monad.tzresult Lwt.t) : _ result =
|
|
|
|
trace_alpha_tzresult tracer @@ Lwt_main.run x
|
2019-05-13 00:46:25 +04:00
|
|
|
|
2020-06-12 15:33:14 +04:00
|
|
|
let trace_tzresult :
|
|
|
|
(tezos_alpha_error list -> _) -> ('a, TP.error list) Pervasives.result -> ('a, _) result =
|
|
|
|
fun tracer err -> match err with
|
2019-12-10 22:00:21 +04:00
|
|
|
| Ok x -> ok x
|
2020-06-12 15:33:14 +04:00
|
|
|
| Error errs -> fail @@ tracer (List.map of_tz_error errs)
|
2019-05-13 00:46:25 +04:00
|
|
|
|
|
|
|
let trace_tzresult_lwt err (x:_ TP.Error_monad.tzresult Lwt.t) : _ result =
|
|
|
|
trace_tzresult err @@ Lwt_main.run x
|