Diff

util/pubsub.lua @ 8316:8648cb171213

util.pubsub: Return item-not-found if a single item is requested, and not there
author Kim Alvefur <zash@zash.se>
date Tue, 10 Oct 2017 01:41:47 +0200
parent 8312:6fd36e73082b
child 8326:12408867bc86
line wrap: on
line diff
--- 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