Module Tezos_dal_node_lib.Errors

type Tezos_base.TzPervasives.error +=
  1. | Decoding_failed of Tezos_dal_node_services.Types.Store.kind
  2. | Profile_incompatibility
  3. | Invalid_slot_index of {
    1. slot_index : int;
    2. number_of_slots : int;
    }
  4. | Cryptobox_initialisation_failed of string
  5. | Not_enough_history of {
    1. stored_levels : int;
    2. minimal_levels : int;
    }
  6. | Not_enough_l1_history of {
    1. stored_cycles : int;
    2. minimal_cycles : int;
    }
  7. | Amplificator_initialization_failed

Extension of the open type error with the errors that could be raised by the DAL node.

The errors below are used to extend tzresult/tztrace monad/errors with Some specific errors on which we'd like to match in the DAL node's code.

type not_found = [
  1. | `Not_found
]

We would like to match `Not_found as we would want to return 404 HTTP code to clients.

type other = [
  1. | `Other of Tezos_base.TzPervasives.tztrace
]

We will use `Other to wrap other tztrace errors in the new polymorphic-variants based monad.

val not_found : [> not_found ]

not_found is an alias for `Not_found.

decoding_failed kind trace produces the error trace Decoding_failed kind :: trace and wraps it with `Other.

other l wraps the give tztrace l in `Other.

val other_result : 'a Tezos_base.TzPervasives.tzresult -> ('a, [> other ]) Stdlib.result

other_result r casts the given value r from the 'a tzresult monad into ('a, [> other_error]) result.

val other_lwt_result : 'a Tezos_base.TzPervasives.tzresult Lwt.t -> ('a, [> other ]) Stdlib.result Lwt.t

other_lwt_result r casts the given value r from the 'a tzresult Lwt.t monad into ('a, [> other]) result Lwt.t.

val to_option_tzresult : ('a, [< not_found | other ]) Stdlib.result Lwt.t -> 'a option Tezos_base.TzPervasives.tzresult Lwt.t

to_option_tzresult v transforms the given value v to another value in the regular 'a option tzresult Lwt.t monad.

Asuming the Lwt monad v successfully resolves, then:

  • If it yields a value Ok w, the function returns an Lwt monad whose payload is Ok (Some w).
  • If it yields a value Error `Not_found, the function returns an Lwt monad whose payload is Ok (None) so that Tezos_rpc_http returns 404 HTTP code.
  • Otherwise, it yields a value Error `Other u. In this case, the function returns an Lwt monad whose payload is Error u.
val to_tzresult : ('a, [< other ]) Stdlib.result Lwt.t -> 'a Tezos_base.TzPervasives.tzresult Lwt.t

to_tzresult v is quite similar to to_option_tzresult. Except that the `Not_found case cannot happen, in which case the use of option for the non-failing case is not needed.