changeset 324:e73e42b4f6ff

pgsql storage: getItemsIndex raise NodeNotFound in this make sense
author Goffi <goffi@goffi.org>
date Fri, 08 Jan 2016 17:27:44 +0100
parents 8496af26be45
children 8d939378f023
files sat_pubsub/pgsql_storage.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Thu Jan 07 16:20:43 2016 +0100
+++ b/sat_pubsub/pgsql_storage.py	Fri Jan 08 17:27:44 2016 +0100
@@ -922,10 +922,12 @@
         query.append(") as x WHERE item=%s")
         args.append(item_id)
 
-
         cursor.execute(' '.join(query), args)
         # XXX: row_number start at 1, but we want that index start at 0
-        return cursor.fetchall()[0][0] - 1
+        try:
+            return cursor.fetchall()[0][0] - 1
+        except IndexError:
+            raise error.NodeNotFound()
 
     def getItemsPublishers(self, itemIdentifiers):
         """Get the publishers for all given identifiers