Browse Source

[server] Better error messages for --connect

Rudy Ges 1 year ago
parent
commit
f00c71ad08
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/compiler/server.ml

+ 5 - 1
src/compiler/server.ml

@@ -898,7 +898,11 @@ let init_wait_stdio() =
 (* The connect function to connect to [host] at [port] and send arguments [args]. *)
 (* The connect function to connect to [host] at [port] and send arguments [args]. *)
 let do_connect host port args =
 let do_connect host port args =
 	let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
 	let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
-	(try Unix.connect sock (Unix.ADDR_INET (Unix.inet_addr_of_string host,port)) with _ -> failwith ("Couldn't connect on " ^ host ^ ":" ^ string_of_int port));
+	(try Unix.connect sock (Unix.ADDR_INET (Unix.inet_addr_of_string host,port)) with
+		| Unix.Unix_error(code,_,_) -> failwith
+			("Couldn't connect on " ^ host ^ ":" ^ string_of_int port ^ " (" ^ (Unix.error_message code) ^ ")");
+		| _ -> failwith ("Couldn't connect on " ^ host ^ ":" ^ string_of_int port)
+	);
 	let rec display_stdin args =
 	let rec display_stdin args =
 		match args with
 		match args with
 		| [] -> ""
 		| [] -> ""