[session] upgrade session closed error from Exception to SessionClosedError
authorpierre-yves
Mon, 27 May 2013 15:48:03 +0200
changeset 8999 81a5d57d9230
parent 8998 4f45968cd956
child 9000 506e656b7eef
[session] upgrade session closed error from Exception to SessionClosedError Exception is far too wide and we already have a SessionClosedError anyway. Closes #2897696
server/session.py
server/test/unittest_repository.py
--- a/server/session.py	Thu Jun 06 12:29:44 2013 +0200
+++ b/server/session.py	Mon May 27 15:48:03 2013 +0200
@@ -1110,7 +1110,7 @@
         """connections set, set according to transaction mode for each query"""
         if self._closed:
             self.free_cnxset(True)
-            raise Exception('try to access connections set on a closed session %s' % self.id)
+            raise SessionClosedError('try to access connections set on a closed session %s' % self.id)
         return self._tx.cnxset
 
     def set_cnxset(self):
@@ -1118,7 +1118,7 @@
         with self._lock: # can probably be removed
             if self._closed:
                 self.free_cnxset(True)
-                raise Exception('try to set connections set on a closed session %s' % self.id)
+                raise SessionClosedError('try to set connections set on a closed session %s' % self.id)
             return self._tx.set_cnxset()
     free_cnxset = tx_meth('free_cnxset')
 
--- a/server/test/unittest_repository.py	Thu Jun 06 12:29:44 2013 +0200
+++ b/server/test/unittest_repository.py	Mon May 27 15:48:03 2013 +0200
@@ -44,6 +44,7 @@
 from cubicweb.server.sqlutils import SQL_PREFIX
 from cubicweb.server.hook import Hook
 from cubicweb.server.sources import native
+from cubicweb.server.session import SessionClosedError
 
 
 class RepositoryTC(CubicWebTC):
@@ -262,7 +263,7 @@
             repo.execute(cnxid, 'DELETE CWUser X WHERE X login "toto"')
             repo.commit(cnxid)
         try:
-            with self.assertRaises(Exception) as cm:
+            with self.assertRaises(SessionClosedError) as cm:
                 run_transaction()
             self.assertEqual(str(cm.exception), 'try to access connections set on a closed session %s' % cnxid)
         finally: