# Module Or_error

    module Or_error: sig .. end

Type for tracking errors in an Error.t. This is a specialization of the Result type, where the Error constructor carries an Error.t.

A common idiom is to wrap a function that is not implemented on all platforms, e.g.:

val do_something_linux_specific : (unit -> unit) Or_error.t

    type 'a t = ('a, Error.t) Result.t

Serialization and comparison of an `Error` force the error's lazy message. *

    include Applicative.S

`Applicative` functions don't have quite the same semantics as `Applicative.of_Monad(Or_error)` would give -- `apply (Error e1) (Error e2)` returns the combination of `e1` and `e2`, whereas it would only return `e1` if it were defined using `bind`.

    include Invariant.S1

    include Monad.S

    val ignore : 'a t -> unit t

    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_join` 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_join : ?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 of_exn_result : ('a, exn) Result.t -> 'a t

`of_exn_result (Ok a) = Ok a`, `of_exn_result (Error exn) = of_exn exn`

    val error : ?strict:unit -> string -> 'a -> ('a -> Sexplib.Sexp.t) -> 'b t

`error` is a wrapper around `Error.create`:

          error ?strict message a sexp_of_a
          = Error (Error.create ?strict message a sexp_of_a)

As with `Error.create`, `sexp_of_a a` is lazily computed, when the info is converted to a sexp. So, if `a` is mutated in the time between the call to `create` and the sexp conversion, those mutations will be reflected in the sexp. Use `~strict:()` to force `sexp_of_a a` to be computed immediately.

    val error_string : string -> 'a t

`error_string message` is `Error (Error.of_string message)`

    val errorf : ('a, unit, string, 'b t) Pervasives.format4 -> 'a

`errorf format arg1 arg2 ...` is `Error (sprintf format arg1 arg2 ...)`. Note that it calculates the string eagerly, so when performance matters you may want to use `error` instead.

    val tag : 'a t -> string -> 'a t

`tag t string` is `Result.map_error t ~f:(fun e -> Error.tag e string)`. `tag_arg` is similar.

    val tag_arg : 'a t -> string -> 'b -> ('b -> Sexplib.Sexp.t) -> 'a t

    val unimplemented : string -> 'a t

For marking a given value as unimplemented. Typically combined with conditional compilation, where on some platforms the function is defined normally, and on some platforms it is defined as unimplemented. The supplied string should be the name of the function that is unimplemented.

    val combine_errors : 'a t list -> 'a list t

`combine_errors ts` returns `Ok` if every element in `ts` is `Ok`, else it returns `Error` with all the errors in `ts`. More precisely:

| combine_errors `Ok a1; ...; Ok an` = Ok `a1; ...; an` | combine_errors `...; Error e1; ...; Error en; ...` | = Error (Error.of_list `e1; ...; en`)

    val combine_errors_unit : unit t list -> unit t

`combine_errors_unit` returns `Ok` if every element in `ts` is `Ok ()`, else it returns `Error` with all the errors in `ts`, like `combine_errors`.

    module Stable: sig .. end

    val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a t

    val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t

    val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

    val bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.t

    val bin_read_t : 'a Bin_prot.Read.reader -> 'a t Bin_prot.Read.reader

    val __bin_read_t__ : 'a Bin_prot.Read.reader -> (int -> 'a t) Bin_prot.Read.reader

    val bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.reader

    val bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizer

    val bin_write_t : 'a Bin_prot.Write.writer -> 'a t Bin_prot.Write.writer

    val bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writer

`Applicative` functions don't have quite the same semantics as `Applicative.of_Monad(Or_error)` would give -- `apply (Error e1) (Error e2)` returns the combination of `e1` and `e2`, whereas it would only return `e1` if it were defined using `bind`.
`try_with f` catches exceptions thrown by `f` and returns them in the Result.t as an Error.t. `try_with_join` 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)`.
defaults to `false`
defaults to `false`
`ok_exn t` throws an exception if `t` is an `Error`, and otherwise returns the contents of the `Ok` constructor.
`of_exn exn` is `Error (Error.of_exn exn)`.
`of_exn_result (Ok a) = Ok a`, `of_exn_result (Error exn) = of_exn exn`
`error` is a wrapper around `Error.create`:

          error ?strict message a sexp_of_a
          = Error (Error.create ?strict message a sexp_of_a)

As with `Error.create`, `sexp_of_a a` is lazily computed, when the info is converted to a sexp. So, if `a` is mutated in the time between the call to `create` and the sexp conversion, those mutations will be reflected in the sexp. Use `~strict:()` to force `sexp_of_a a` to be computed immediately.
`error_string message` is `Error (Error.of_string message)`
`errorf format arg1 arg2 ...` is `Error (sprintf format arg1 arg2 ...)`. Note that it calculates the string eagerly, so when performance matters you may want to use `error` instead.
`tag t string` is `Result.map_error t ~f:(fun e -> Error.tag e string)`. `tag_arg` is similar.
For marking a given value as unimplemented. Typically combined with conditional compilation, where on some platforms the function is defined normally, and on some platforms it is defined as unimplemented. The supplied string should be the name of the function that is unimplemented.
`combine_errors ts` returns `Ok` if every element in `ts` is `Ok`, else it returns `Error` with all the errors in `ts`. More precisely:

| combine_errors `Ok a1; ...; Ok an` = Ok `a1; ...; an` | combine_errors `...; Error e1; ...; Error en; ...` | = Error (Error.of_list `e1; ...; en`)
`combine_errors_unit` returns `Ok` if every element in `ts` is `Ok ()`, else it returns `Error` with all the errors in `ts`, like `combine_errors`.
`Or_error.t` is wire compatible with `V2.t`, but not `V1.t`, like `Info.Stable` and `Error.Stable`.