浏览代码

added proper exception on connect.

Nicolas Cannasse 19 年之前
父节点
当前提交
35cfa8d44a
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      std/neko/io/Socket.hx

+ 8 - 1
std/neko/io/Socket.hx

@@ -64,7 +64,14 @@ class Socket {
 	}
 
 	public function connect(host : Host, port : Int) {
-		socket_connect(__s, host, port);
+		try {
+			socket_connect(__s, host, port);
+		} catch( s : String ) {
+			if( s == "std@socket_connect" )
+				throw "Failed to connect on "+reverse(host)+":"+port;
+			else
+				neko.Lib.rethrow(s);
+		}
 	}
 
 	public function listen(connections : Int) {