@@ -5,8 +5,8 @@ type error = [ `Cancelled | `Exit_code of int | `Msg of string ]
55let send_to ch contents =
66 Lwt. try_bind
77 (fun () -> Lwt_io. write ch contents >> = fun () -> Lwt_io. close ch)
8- (fun () -> Lwt . return (Ok () ))
9- (fun ex -> Lwt. return (Error ( `Msg ( Printexc. to_string ex)) ))
8+ (fun () -> Lwt_result . return () )
9+ (fun ex -> Lwt. return (Fmt. error_msg " %a " Fmt. exn ex))
1010
1111let pp_signal f x =
1212 let open Sys in
@@ -34,19 +34,17 @@ let exec ~label ~log ~switch ?env ?(stdin = "") ?(stderr = `FD_copy Unix.stdout)
3434 | _ when not (Lwt_switch. is_on switch) -> Error `Cancelled
3535 | Unix. WEXITED n when is_success n -> (
3636 match stdin_result with
37- | Ok () -> Ok ()
37+ | Ok _ as ok -> ok
3838 | Error (`Msg msg ) ->
39- Error ( `Msg ( Fmt. str " Failed sending input to %s: %s" label msg)) )
39+ Fmt. error_msg " Failed sending input to %s: %s" label msg)
4040 | Unix. WEXITED n -> Error (`Exit_code n)
41- | Unix. WSIGNALED x ->
42- Error (`Msg (Fmt. str " %s failed with signal %d" label x))
41+ | Unix. WSIGNALED x -> Fmt. error_msg " %s failed with signal %d" label x
4342 | Unix. WSTOPPED x ->
44- Error ( `Msg ( Fmt. str " %s stopped with signal %a" label pp_signal x))
43+ Fmt. error_msg " %s stopped with signal %a" label pp_signal x
4544
4645let check_call ~label ~log ~switch ?env ?stdin ?stderr ?is_success cmd =
4746 exec ~label ~log ~switch ?env ?stdin ?stderr ?is_success cmd > |= function
4847 | Ok () -> Ok ()
4948 | Error `Cancelled -> Error `Cancelled
50- | Error (`Exit_code n ) ->
51- Error (`Msg (Fmt. str " %s failed with exit-code %d" label n))
49+ | Error (`Exit_code n ) -> Fmt. error_msg " %s failed with exit-code %d" label n
5250 | Error (`Msg _ ) as e -> e
0 commit comments