let catch_deferred f : (_, _) t = Deferred.catch (fun () -> let a_exn_m : 'a Deferred.t = f () in Deferred.bind a_exn_m (fun x -> Deferred.return (`Ok x))) (fun e -> Deferred.return (`Error e))