Changeset

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
parents 8315:967f04fe7fd4
children 8317:ff57b3cc5a8e
files util/pubsub.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
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