Source

spotlib / lib / exn.mli

The default branch has multiple heads

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

val failwithf    : ('a, unit, string, 'b) format4 -> 'a
val failwith     : ('a, unit, string, 'b) format4 -> 'a
(** [failwith] is overridden by [failwithf], since

    Mistyping [failwith "hello %s" "world"] instead of [failwithf "hello %s" "world"]
    ignores the second argument.

    Use [Pervasives.failwith] if you need one with type : string -> 'a
 *) 

val invalid_argf : ('a, unit, string, 'b) format4 -> 'a
val invalid_arg  : ('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 *)