module Error: Error
type
t
include Sexpable.S
include Binable.S
val to_sexp_hum : t -> Sexplib.Sexp.t
to_sexp_hum t
returns t
formatted as sexp that aims to be readable. This loses
information about the structure of the error, so if the result is converted back using
t_of_sexp
, it will not be able to pretty print as nicely. That is, the following
equalities do not necessarily hold:
to_sexp_hum (t_of_sexp (to_sexp_hum t)) = to_sexp_hum t
to_string_hum (t_of_sexp (to_sexp_hum t)) = to_string_hum t
val to_string_hum : t -> string
val of_string : string -> t
val of_lazy : string Lazy.t -> t
val of_thunk : (unit -> string) -> t
val create : string -> 'a -> ('a -> Sexplib.Sexp.t) -> t
create msg z sexp_of_z
, be careful to use only immutable values for z, or be
aware that z
will be lazily converted to a sexp at a later point in time, which will
pick up the then-current state of z
.val tag : t -> string -> t
val tag_arg : t -> string -> 'a -> ('a -> Sexplib.Sexp.t) -> t
val of_list : ?trunc_after:int -> t list -> t
val of_exn : ?backtrace:[ `Get | `This of string ] -> exn -> t
val to_exn : t -> exn
val raise : t -> 'a
val failwiths : string -> 'a -> ('a -> Sexplib.Sexp.t) -> 'b
failwiths message value sexp_of_value
raises an exception with the supplied
message
and value
, by constructing an Error.t
and using Error.raise
. As
usual, the sexp_of_value
is only applied when the value is converted to a sexp or a
string. So, if you mutate value
in between the time you call failwiths
and the
time the error is displayed, those mutations will be reflected in the error message.
failwiths s a f
= Error.raise (Error.create s a f)
val pp : Format.formatter -> t -> unit