add try except to avoid error w/ unsupported stuff, log it and return incomplete filter form
authorSylvain Thenault <sylvain.thenault@logilab.fr>
Wed, 07 Jan 2009 15:36:59 +0100
changeset 346 5bbb01a133ae
parent 342 6becc066fc00
child 347 2e48b50ce635
add try except to avoid error w/ unsupported stuff, log it and return incomplete filter form
web/facet.py
--- a/web/facet.py	Wed Jan 07 15:00:30 2009 +0100
+++ b/web/facet.py	Wed Jan 07 15:36:59 2009 +0100
@@ -356,7 +356,12 @@
             mainvar = self.filtered_variable
             insert_attr_select_relation(rqlst, mainvar, self.rtype, self.role,
                                         self.target_attr, self.sortfunc, self.sortasc)
-            rset = self.rqlexec(rqlst.as_string(), self.rset.args, self.rset.cachekey)
+            try:
+                rset = self.rqlexec(rqlst.as_string(), self.rset.args, self.rset.cachekey)
+            except:
+                self.exception('error while getting vocabulary for %s, rql: %s',
+                               self, rqlst.as_string())
+                return ()
         finally:
             rqlst.recover()
         return self.rset_vocabulary(rset)
@@ -436,8 +441,12 @@
             _cleanup_rqlst(rqlst, mainvar)
             newvar, rel = _prepare_vocabulary_rqlst(rqlst, mainvar, self.rtype, self.role)
             _set_orderby(rqlst, newvar, self.sortasc, self.sortfunc)
-            rset = self.rqlexec(rqlst.as_string(), self.rset.args,
-                                self.rset.cachekey)
+            try:
+                rset = self.rqlexec(rqlst.as_string(), self.rset.args, self.rset.cachekey)
+            except:
+                self.exception('error while getting vocabulary for %s, rql: %s',
+                               self, rqlst.as_string())
+                return ()
         finally:
             rqlst.recover()
         return self.rset_vocabulary(rset)