let wrap_deferred ~on_exn f = let caught = catch_deferred f in caught >>< function | `Ok o -> return o | `Error e -> fail (on_exn e)