CCError.fail_printf

This commit is contained in:
Simon Cruanes 2014-07-11 23:05:13 +02:00
parent b93d68ad8d
commit 4ca1295c44
2 changed files with 11 additions and 0 deletions

View file

@ -43,6 +43,12 @@ let return x = `Ok x
let fail s = `Error s
let fail_printf format =
let buf = Buffer.create 16 in
Printf.kbprintf
(fun buf -> fail (Buffer.contents buf))
buf format
let _printers = ref []
let register_printer p = _printers := p :: !_printers

View file

@ -45,6 +45,11 @@ val fail : string -> 'a t
val of_exn : exn -> 'a t
val fail_printf : ('a, Buffer.t, unit, 'a t) format4 -> 'a
(** [fail_printf format] uses [format] to obtain an error message
and then returns [`Error msg]
@since NEXT_VERSION *)
val map : ('a -> 'b) -> 'a t -> 'b t
val map2 : ('a -> 'b) -> (string -> string) -> 'a t -> 'b t