From 42c4c310b4ad755ff75b7ee2ff9bd65c4d79541c Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 3 Oct 2015 08:56:49 +0200 Subject: [PATCH] add `CCError.guard_str_trace` --- src/core/CCError.ml | 4 ++++ src/core/CCError.mli | 5 +++++ 2 files changed, 9 insertions(+) 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. *)