Browse Source

[1366] Throw an exception if DummyIOCallback() is called

Mukund Sivaraman 11 years ago
parent
commit
5dfa164e05
1 changed files with 16 additions and 15 deletions
  1. 16 15
      src/lib/asiolink/dummy_io_cb.h

+ 16 - 15
src/lib/asiolink/dummy_io_cb.h

@@ -15,9 +15,10 @@
 #ifndef DUMMY_IO_CB_H
 #define DUMMY_IO_CB_H
 
-#include <cassert>
 #include <iostream>
 
+#include <exceptions/exceptions.h>
+
 #include <asio/error.hpp>
 #include <asio/error_code.hpp>
 
@@ -43,13 +44,13 @@ public:
     /// Should never be called, as this class is a convenience class provided
     /// for instances where a socket is required but it is known that no
     /// asynchronous operations will be carried out.
-    void operator()(asio::error_code)
-    {
-        // If the function is called, there is a serious logic error in the
-        // program (this class should not be used as the callback class).  As
-        // the asiolink module is too low-level for logging errors, use assert()
-        // to bug-check the program.
-        assert(false);
+    void operator()(asio::error_code) {
+        // If the function is called, there is a serious logic error in
+        // the program (this class should not be used as the callback
+        // class).  As the asiolink module is too low-level for logging
+        // errors, throw an exception.
+        isc_throw(isc::Unexpected,
+                  "DummyIOCallback::operator() must not be called");
     }
 
     /// \brief Asynchronous I/O callback method
@@ -57,13 +58,13 @@ public:
     /// Should never be called, as this class is a convenience class provided
     /// for instances where a socket is required but it is known that no
     /// asynchronous operations will be carried out.
-    void operator()(asio::error_code, size_t)
-    {
-        // If the function is called, there is a serious logic error in the
-        // program (this class should not be used as the callback class).  As
-        // the asiolink module is too low-level for logging errors, use assert()
-        // to bug-check the program.
-        assert(false);
+    void operator()(asio::error_code, size_t) {
+        // If the function is called, there is a serious logic error in
+        // the program (this class should not be used as the callback
+        // class).  As the asiolink module is too low-level for logging
+        // errors, throw an exception.
+        isc_throw(isc::Unexpected,
+                  "DummyIOCallback::operator() must not be called");
     }
 };