Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/rpc/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module Connection = struct

let connect_sock sock = Csexp_rpc.Client.create sock |> Csexp_rpc.Client.connect

let connect_error where detail =
User_error.make
[ Pp.textf "failed to connect to RPC server %s" (Where.to_string where); detail ]
;;

let of_fd fd =
match Csexp_rpc.Session.of_fd fd with
| fd -> fd
Expand All @@ -29,23 +34,12 @@ module Connection = struct

let connect where =
match Where.to_socket where with
| exception exn ->
Fiber.return
(Error
(User_error.make
[ Pp.textf "failed to connect to RPC server %s" (Where.to_string where)
; Exn.pp exn
]))
| exception exn -> Fiber.return (Error (connect_error where (Exn.pp exn)))
| sock ->
connect_sock sock
>>| (function
| Ok s -> Ok s
| Error exn ->
Error
(User_error.make
[ Pp.textf "failed to connect to RPC server %s" (Where.to_string where)
; Exn_with_backtrace.pp exn
]))
| Error exn -> Error (connect_error where (Exn_with_backtrace.pp exn)))
;;

let connect_exn where = connect where >>| User_error.ok_exn
Expand Down
Loading