mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
fix too restrictive type in CCResult
This commit is contained in:
parent
c7b1afca82
commit
af6cd08ff4
2 changed files with 10 additions and 2 deletions
|
|
@ -24,6 +24,10 @@ let fail_printf format =
|
|||
(fun buf -> fail (Buffer.contents buf))
|
||||
buf format
|
||||
|
||||
(*$T
|
||||
(Error "ohno 42") = (fail_printf "ohno %d" 42)
|
||||
*)
|
||||
|
||||
let fail_fprintf format =
|
||||
let buf = Buffer.create 64 in
|
||||
let out = Format.formatter_of_buffer buf in
|
||||
|
|
@ -31,6 +35,10 @@ let fail_fprintf format =
|
|||
(fun out -> Format.pp_print_flush out (); fail (Buffer.contents buf))
|
||||
out format
|
||||
|
||||
(*$T
|
||||
(Error "ohno 42") = (fail_fprintf "ohno %d" 42)
|
||||
*)
|
||||
|
||||
let add_ctx msg x = match x with
|
||||
| Error e -> Error (e ^ "\ncontext:" ^ msg)
|
||||
| Ok x -> Ok x
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ val of_exn_trace : exn -> ('a, string) t
|
|||
Remember to call [Printexc.record_backtrace true] and compile with the
|
||||
debug flag for this to work. *)
|
||||
|
||||
val fail_printf : ('a, Buffer.t, unit, ('a, string) t) format4 -> 'a
|
||||
val fail_printf : ('a, Buffer.t, unit, ('b, string) t) format4 -> 'a
|
||||
(** [fail_printf format] uses [format] to obtain an error message
|
||||
and then returns [Error msg] *)
|
||||
|
||||
val fail_fprintf : ('a, Format.formatter, unit, ('a, string) t) format4 -> 'a
|
||||
val fail_fprintf : ('a, Format.formatter, unit, ('b, string) t) format4 -> 'a
|
||||
(** [fail_printf format] uses [format] to obtain an error message
|
||||
and then returns [Error msg] *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue