package octez-proto-libs
Signature from Lwtreslib's option module
val none_e : ('a option, 'trace) Pervasives.result
val none_s : 'a option Lwt.t
val none_es : ('a option, 'trace) Pervasives.result Lwt.t
val some_e : 'a -> ('a option, 'trace) Pervasives.result
val some_s : 'a -> 'a option Lwt.t
val some_es : 'a -> ('a option, 'trace) Pervasives.result Lwt.t
val value_e : 'a option -> error:'trace -> ('a, 'trace) Pervasives.result
val value_fe :
'a option ->
error:(unit -> 'trace) ->
('a, 'trace) Pervasives.result
val map_e :
('a -> ('b, 'trace) Pervasives.result) ->
'a option ->
('b option, 'trace) Pervasives.result
val map_es :
('a -> ('b, 'trace) Pervasives.result Lwt.t) ->
'a option ->
('b option, 'trace) Pervasives.result Lwt.t
val iter_e :
('a -> (unit, 'trace) Pervasives.result) ->
'a option ->
(unit, 'trace) Pervasives.result
val iter_es :
('a -> (unit, 'trace) Pervasives.result Lwt.t) ->
'a option ->
(unit, 'trace) Pervasives.result Lwt.t
val to_result : none:'trace -> 'a option -> ('a, 'trace) Pervasives.result
val of_result : ('a, 'e) Pervasives.result -> 'a option
val to_seq : 'a option -> 'a Seq.t
catch f
is Some (f ())
if f
does not raise an exception, it is None
otherwise.
You should only use catch
when you truly do not care about what exception may be raised during the evaluation of f ()
. If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch
instead.
If catch_only
is set, then only exceptions e
such that catch_only e
is true
are caught.
Whether catch_only
is set or not, you cannot catch non-deterministic runtime exceptions of OCaml such as Stack_overflow
and Out_of_memory
nor system exceptions such as Unix.Unix_error
.
catch_s f
is a promise that resolves to Some x
if and when f ()
resolves to x
. Alternatively, it resolves to None
if and when f ()
is rejected.
You should only use catch_s
when you truly do not care about what exception may be raised during the evaluation of f ()
. If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch_s
instead.
If catch_only
is set, then only exceptions e
such that catch_only e
is true
are caught.
Whether catch_only
is set or not, you cannot catch non-deterministic runtime exceptions of OCaml such as Stack_overflow
and Out_of_memory
nor system exceptions such as Unix.Unix_error
.