plugins/mod_storage_internal.lua
changeset 10022 7408b9473729
parent 10005 55f5588d71c6
child 10028 4a0d990253a0
--- a/plugins/mod_storage_internal.lua	Sun May 26 19:41:58 2019 +0200
+++ b/plugins/mod_storage_internal.lua	Tue Mar 05 00:12:30 2019 +0100
@@ -161,20 +161,30 @@
 		if query.reverse then
 			items:reverse();
 			if query.before then
+				local found = false;
 				for j = 1, #items do
 					if (items[j].key or tostring(j)) == query.before then
+						found = true;
 						i = j;
 						break;
 					end
 				end
+				if not found then
+					return nil, "item-not-found";
+				end
 			end
 		elseif query.after then
+			local found = false;
 			for j = 1, #items do
 				if (items[j].key or tostring(j)) == query.after then
+					found = true;
 					i = j;
 					break;
 				end
 			end
+			if not found then
+				return nil, "item-not-found";
+			end
 		end
 		if query.limit and #items - i > query.limit then
 			items[i+query.limit+1] = nil;