Diff

clix.lua @ 11:a502c905527c

clix: Handle errors (including 'interrupted!') in verse.loop()
author Matthew Wild <mwild1@gmail.com>
date Thu, 07 Jan 2010 02:31:00 +0000
parent 8:df4cb4a73549
child 13:751db005032e
line wrap: on
line diff
--- a/clix.lua	Thu Jan 07 02:20:16 2010 +0000
+++ b/clix.lua	Thu Jan 07 02:31:00 2010 +0000
@@ -81,7 +81,13 @@
 	conn.connect_port = account.port;
 	-- Connect!
 	conn:connect_client(account.jid, account.password);
-	return verse.loop();
+	
+	local ok, ret = pcall(verse.loop);
+	if not ok and not ret:match("interrupted!$") then
+		io.stderr:write("Fatal error: ", ret, "\n");
+		return 1;
+	end
+	return err or 0;
 end
 
 table.remove(arg,1);