Module Imandrakit_error.Error_core

Universal error type for Imandrakit.

type message = {
  1. msg : string;
  2. data : Data.t;
  3. bt : string option;
    (*

    Backtrace

    *)
}

A message.

An error message is emitted at a particular place in the code. An error can contain several error messages.

type stack = message list
type t = {
  1. process : string;
  2. kind : Kind.t;
  3. msg : message;
  4. stack : stack;
}
exception E of t

Internal error

val pp_with : show_process:bool -> t Imandrakit_common.Fmt.printer
module Message : sig ... end
val data : t -> Data.t
val get_data : 'a Data.key -> t -> 'a option
val raise_err : ?bt:Stdlib.Printexc.raw_backtrace -> t -> 'a
val add_bt : string -> t -> t
val add_ctx : message -> t -> t
val add_data : 'a Data.key -> 'a -> t -> t
val guard : ?let_pass:(exn -> bool) -> (unit -> message) -> (unit -> 'a) -> 'a

guard g f behaves like f(), excepts that if f() raises Error e, guard g f raises Error e' where e' wraps e with context error g().

  • parameter let_pass

    if it returns true for an exception, the exception is re-raised.

type !'a result = ('a, t) result
val map_result : ('a -> 'b) -> 'a result -> 'b result
val unwrap : 'a result -> 'a

unwrap e uses raise_err to unpack the result

module Infix : sig ... end
include module type of Infix
val let*! : (unit -> message) -> (unit -> 'a) -> 'a

Similar to guard