ligo/vendors/ligo-utils/proto-alpha-utils/x_error_monad.ml

27 lines
697 B
OCaml
Raw Permalink Normal View History

2019-05-13 00:46:25 +04:00
include Tezos_error_monad.Error_monad
include Tezos_utils.Error_monad
open Memory_proto_alpha
let (>>??) = Alpha_environment.Error_monad.(>>?)
let alpha_wrap a = Alpha_environment.wrap_error a
2019-11-19 18:31:36 +04:00
let alpha_error_wrap x = Memory_proto_alpha.Alpha_environment.Ecoproto_error x
2019-05-13 00:46:25 +04:00
let force_ok_alpha ~msg a = force_ok ~msg @@ alpha_wrap a
let force_lwt ~msg a = force_ok ~msg @@ Lwt_main.run a
let force_lwt_alpha ~msg a = force_ok ~msg @@ alpha_wrap @@ Lwt_main.run a
let assert_error () = function
| Ok _ -> fail @@ failure "assert_error"
| Error _ -> return ()
let (>>=??) a f =
a >>= fun a ->
match alpha_wrap a with
| Ok result -> f result
| Error errs -> Lwt.return (Error errs)