diff options
author | iproctor <dev-null@apache.org> | 2007-08-17 21:34:15 +0000 |
---|---|---|
committer | iproctor <dev-null@apache.org> | 2007-08-17 21:34:15 +0000 |
commit | 94112d699411fcca2bde9721da46ddcd4c15a5bf (patch) | |
tree | 27b1be8d7ab83fb58e1130460cfa1d58a1451f44 /lib/ocaml | |
parent | 937fa6258bc4f9509dbaf914108cf2d381c8f741 (diff) | |
download | thrift-94112d699411fcca2bde9721da46ddcd4c15a5bf.tar.gz |
Thrift: OCaml TSocket more helpful exceptions
Summary: On unix error it tells you the cause.
Reviewed by: mcslee
Test plan: Had some unix errors, read the messages.
Revert plan: yes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665208 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib/ocaml')
-rw-r--r-- | lib/ocaml/src/TSocket.ml | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ocaml/src/TSocket.ml b/lib/ocaml/src/TSocket.ml index c74864a97..20c861322 100644 --- a/lib/ocaml/src/TSocket.ml +++ b/lib/ocaml/src/TSocket.ml @@ -11,8 +11,9 @@ object (self) try let addr = (let {Unix.h_addr_list=x} = Unix.gethostbyname host in x.(0)) in chans <- Some(Unix.open_connection (Unix.ADDR_INET (addr,port))) - with _ -> - raise (T.E (T.NOT_OPEN, ("TSocket: Could not connect to "^host^":"^(string_of_int port)))) + with + Unix.Unix_error (e,fn,_) -> raise (T.E (T.NOT_OPEN, ("TSocket: Could not connect to "^host^":"^(string_of_int port)^" because: "^fn^":"^(Unix.error_message e)))) + | _ -> raise (T.E (T.NOT_OPEN, ("TSocket: Could not connect to "^host^":"^(string_of_int port)))) method close = match chans with @@ -25,7 +26,9 @@ object (self) | Some(i,o) -> try really_input i buf off len; len - with _ -> raise (T.E (T.UNKNOWN, ("TSocket: Could not read "^(string_of_int len)^" from "^host^":"^(string_of_int port)))) + with + Unix.Unix_error (e,fn,_) -> raise (T.E (T.UNKNOWN, ("TSocket: Could not read "^(string_of_int len)^" from "^host^":"^(string_of_int port)^" because: "^fn^":"^(Unix.error_message e)))) + | _ -> raise (T.E (T.UNKNOWN, ("TSocket: Could not read "^(string_of_int len)^" from "^host^":"^(string_of_int port)))) method write buf off len = match chans with None -> raise (T.E (T.NOT_OPEN, "TSocket: Socket not open")) | Some(i,o) -> output o buf off len |