clix: Handle errors (including 'interrupted!') in verse.loop()

Thu, 07 Jan 2010 02:31:00 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 07 Jan 2010 02:31:00 +0000
changeset 11
a502c905527c
parent 10
49b83fa1f6fd
child 12
1793fca3d707

clix: Handle errors (including 'interrupted!') in verse.loop()

clix.lua file | annotate | diff | comparison | revisions
--- 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);

mercurial