mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-24 18:16:40 -05:00
CCError.fail_printf
This commit is contained in:
parent
b93d68ad8d
commit
4ca1295c44
2 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue