diff --git a/src/core/CCError.ml b/src/core/CCError.ml index 97c06432..20746abd 100644 --- a/src/core/CCError.ml +++ b/src/core/CCError.ml @@ -139,6 +139,10 @@ let guard_str f = try `Ok (f()) with e -> of_exn e +let guard_str_trace f = + try `Ok (f()) + with e -> of_exn_trace e + let wrap1 f x = try return (f x) with e -> `Error e diff --git a/src/core/CCError.mli b/src/core/CCError.mli index cfd11249..877e5874 100644 --- a/src/core/CCError.mli +++ b/src/core/CCError.mli @@ -118,6 +118,11 @@ val guard_str : (unit -> 'a) -> ('a, string) t (** Same as {!guard} but uses {!of_exn} to print the exception. See {!register_printer} *) +val guard_str_trace : (unit -> 'a) -> ('a, string) t +(** Same as {!guard_str} but uses {!of_exn_trace} instead of {!of_exn} so + that the stack trace is printed. + @since NEXT_RELEASE *) + val wrap1 : ('a -> 'b) -> 'a -> ('b, exn) t (** Same as {!guard} but gives the function one argument. *)