Better handling of timeouts (or other errors), and allow matching errors with false

Fri, 10 Aug 2012 13:02:10 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 10 Aug 2012 13:02:10 +0100
changeset 15
1b59ba3e9508
parent 14
a8f632e88555
child 16
872dc69f6039

Better handling of timeouts (or other errors), and allow matching errors with false

xmpp-fingerprint.lua file | annotate | diff | comparison | revisions
--- a/xmpp-fingerprint.lua	Sun Jun 05 16:32:20 2011 +0100
+++ b/xmpp-fingerprint.lua	Fri Aug 10 13:02:10 2012 +0100
@@ -95,9 +95,17 @@
 		received = data or partial or "";
 		conn:close();
 		received_cache[question] = received;
-		debug("<<", #received ~= "" and tostring(received) or nil);
+		if received ~= "" then
+			debug("<<", received);
+		else
+			debug("!!", tostring(err));
+		end
 	end
-	return received ~= "" and received:match(answer);
+	if received == "" then
+		return answer == false
+	elseif answer then
+		return received:match(answer);
+	end
 end
 
 function test(question, answer)

mercurial