util.pubsub: Return item-not-found if a single item is requested, and not there
authorKim Alvefur <zash@zash.se>
Tue, 10 Oct 2017 01:41:47 +0200
changeset 8319 8648cb171213
parent 8318 967f04fe7fd4
child 8320 ff57b3cc5a8e
util.pubsub: Return item-not-found if a single item is requested, and not there
util/pubsub.lua
--- a/util/pubsub.lua	Mon Oct 09 13:45:53 2017 +0200
+++ b/util/pubsub.lua	Tue Oct 10 01:41:47 2017 +0200
@@ -338,7 +338,11 @@
 		return false, "item-not-found";
 	end
 	if id then -- Restrict results to a single specific item
-		return true, { id, [id] = self.data[node]:get(id) };
+		local with_id = self.data[node]:get(id);
+		if not with_id then
+			return false, "item-not-found";
+		end
+		return true, { id, [id] = with_id };
 	else
 		local data = {}
 		for key, value in self.data[node]:items() do