Browse Source

[1542] Different rcodes for expected exceptions

Michal 'vorner' Vaner 13 years ago
parent
commit
efcff547c5
2 changed files with 11 additions and 0 deletions
  1. 4 0
      src/bin/bind10/bind10_src.py.in
  2. 7 0
      src/bin/bind10/tests/bind10_test.py.in

+ 4 - 0
src/bin/bind10/bind10_src.py.in

@@ -805,6 +805,10 @@ class BoB:
                 'token': token,
                 'token': token,
                 'path': self._socket_path
                 'path': self._socket_path
             })
             })
+        except isc.bind10.socket_cache.SocketError as e:
+            return isc.config.ccsession.create_answer(2, str(e))
+        except isc.bind10.socket_cache.ShareError as e:
+            return isc.config.ccsession.create_answer(3, str(e))
         except Exception as e:
         except Exception as e:
             return isc.config.ccsession.create_answer(1, str(e))
             return isc.config.ccsession.create_answer(1, str(e))
 
 

+ 7 - 0
src/bin/bind10/tests/bind10_test.py.in

@@ -296,6 +296,13 @@ class TestCacheCommands(unittest.TestCase):
         # to an error, not propagated
         # to an error, not propagated
         self.__raise_exception = Exception("Test exception")
         self.__raise_exception = Exception("Test exception")
         check_code(1, self.__socket_args)
         check_code(1, self.__socket_args)
+        # The special "expected" exceptions
+        self.__raise_exception = \
+            isc.bind10.socket_cache.ShareError("Not shared")
+        check_code(3, self.__socket_args)
+        self.__raise_exception = \
+            isc.bind10.socket_cache.SocketError("Not shared", 13)
+        check_code(2, self.__socket_args)
 
 
     def drop_socket(self, token):
     def drop_socket(self, token):
         """
         """