Commit 23d6ef87 authored by Johannes Kanig's avatar Johannes Kanig Committed by Sylvain Dailler

QC06-011 improve error when socket file cannot be created

When the socket file cannot be created, raise an exception instead of
exiting.  This allows a nice error message to be printed.

* prove_client.ml
(client_connect): in case of error, do not exit, but raise exception

Change-Id: I83fb36a431bf4d854a23d93b0b870fa3d0db7526
(cherry picked from commit b18ffc3f742cf8738533994119857328e7dc8633)
parent fb3da6dc
......@@ -14,6 +14,7 @@ let socket : Unix.file_descr option ref = ref None
exception NotConnected
exception AlreadyConnected
exception InvalidAnswer of string
exception ConnectionError of string
let is_connected () = !socket <> None
......@@ -32,12 +33,13 @@ let client_connect ~fail socket_name =
socket := Some sock
with
| Unix.Unix_error(err, func, arg) when fail ->
Format.eprintf "client_connect: connection failed: %s (%s,%s) (socket_name=%s)@." (Unix.error_message err) func arg socket_name;
exit 2
let s = Format.sprintf "client_connect: connection failed: %s (%s,%s) (socket_name=%s)@."
(Unix.error_message err) func arg socket_name in
raise (ConnectionError s)
| e when fail ->
Format.eprintf "client_connect failed for some unexpected reason: %s@\nAborting.@."
(Printexc.to_string e);
exit 2
let s = Format.sprintf "client_connect failed for some unexpected reason: %s@\nAborting.@."
(Printexc.to_string e) in
raise (ConnectionError s)
let client_disconnect () =
match !socket with
......
......@@ -10,6 +10,7 @@
(********************************************************************)
exception AlreadyConnected
exception ConnectionError of string
val connect_external : string -> unit
(** connects to an already running server, with the given socket name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment