module Or_error: Or_error
type 'a
t = ('a, Error.t) Result.t
include Sexpable.S1
include Binable.S1
include Monad.S
val try_with : ?backtrace:bool -> (unit -> 'a) -> 'a t
try_with f
catches exceptions thrown by f
and returns them in the Result.t as an
Error.t. try_with_bind
is like try_with
, except that f
can throw exceptions or
return an Error directly, without ending up with a nested error; it is equivalent to
Result.join (try_with f)
.
val try_with_bind : ?backtrace:bool -> (unit -> 'a t) -> 'a t
val ok_exn : 'a t -> 'a
ok_exn t
throws an exception if t
is an Error
, and otherwise returns the
contents of the Ok
constructor.
val of_exn : ?backtrace:[ `Get | `This of string ] -> exn -> 'a t
of_exn exn
is Error (Error.of_exn exn)
.
val error : string -> 'a -> ('a -> Sexplib.Sexp.t) -> 'b t
error message value sexp_of_value
constructs an Error.t
and returns it as a
Result.Error
. error_string
is a sepcial case with 'a = unit
.
val error_string : string -> 'a t
val unimplemented : string -> 'a t
unimplemented name
returns a standard error value for an unimplemented value.