Source

spotlib / lib / exn.mli

Full commit
(** {6 Printf style errors } *)

val failwithf    : ('a, unit, string, 'b) format4 -> 'a

val invalid_argf : ('a, unit, string, 'b) format4 -> 'a

(** {6 Exception handling } *)

exception Finally of exn * exn

val protect     : f:('a -> 'b) -> 'a -> finally: ('a -> unit) -> 'b
val with_final : 'a -> ('a -> 'b) -> ('a -> unit) -> 'b
(** same as [protect] *)

val catch       : f:('a -> 'b) -> 'a -> [> ('b, exn) Result.t ]
val try_ignore  : f:('a -> unit) -> 'a -> unit
val try_default : default: ('a -> 'b) -> f: ('a -> 'b) -> 'a -> 'b
val try_bool    : f:('a -> 'b) -> 'a -> bool
(** [true] at success *)

val protect'     : (unit -> 'a) -> finally: (unit -> unit) -> 'a
val catch'       : (unit -> 'a) -> [> ('a, exn) Result.t ]
val try_ignore'  : (unit -> unit) -> unit
val try_default' : default: (unit -> 'a) -> (unit -> 'a) -> 'a
val try_bool'    : (unit -> unit) -> bool (* success/fail *)
(** [true] at success *)

(* Printexc + alpha *)

val to_string : exn -> string
val format : Format.formatter -> exn -> unit
val print_backtrace : out_channel -> unit
val get_backtrace : unit -> string
val register_printer : (exn -> string option) -> unit