changeset 429:0526073ff2ab

pgsql: replaced ValueError by BadRequest: `BadRequest` results in a proper IQ error, while `ValueError` results in an InternalError.
author Goffi <goffi@goffi.org>
date Thu, 10 Dec 2020 10:46:34 +0100
parents 34bd55179e22
children 5a0ada3b61ca
files sat_pubsub/pgsql_storage.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Fri Oct 09 18:26:50 2020 +0200
+++ b/sat_pubsub/pgsql_storage.py	Thu Dec 10 10:46:34 2020 +0100
@@ -61,7 +61,7 @@
 from twisted.python import log
 
 from wokkel import generic
-from wokkel.pubsub import Subscription
+from wokkel.pubsub import Subscription, BadRequest
 
 from sat_pubsub import error
 from sat_pubsub import iidavoll
@@ -174,7 +174,7 @@
             node.dbpool = self.dbpool
             return node
         else:
-            raise ValueError("Unknown node type !")
+            raise BadRequest(text="Unknown node type !")
 
     def getNodeById(self, nodeDbId):
         """Get node using database ID insted of pubsub identifier
@@ -433,7 +433,7 @@
     def getLastItems(self, entities, nodes, node_accesses, item_accesses, pep):
         """get last item for several nodes and entities in a single request"""
         if not entities or not nodes or not node_accesses or not item_accesses:
-            raise ValueError("entities, nodes and accesses must not be empty")
+            raise BadRequest(text="entities, nodes and accesses must not be empty")
         if node_accesses != ('open',) or item_accesses != ('open',):
             raise NotImplementedError('only "open" access model is handled for now')
         if not pep: