This commit is contained in:
Jeremie Dimino 2016-12-07 17:05:53 +01:00
parent 0dd0511581
commit b80929774a
1 changed files with 9 additions and 6 deletions

View File

@ -88,12 +88,15 @@ let ( >>= ) t f =
let ( >>| ) t f = t >>= fun x -> return (f x) let ( >>| ) t f = t >>= fun x -> return (f x)
let with_exn_handler f ~handler = let with_exn_handler f ~handler =
protectx !exn_handler let saved = !exn_handler in
~finally:(fun saved -> exn_handler := handler;
exn_handler := saved) match f () with
~f:(fun _ -> | x -> exn_handler := saved; x
exn_handler := handler; | exception exn ->
f ()) let bt = Printexc.get_raw_backtrace () in
exn_handler := saved;
handler exn bt;
reraise exn
let both a b = let both a b =
a >>= fun a -> a >>= fun a ->