]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1366] Throw an exception if DummyIOCallback() is called
authorMukund Sivaraman <muks@isc.org>
Thu, 30 Jan 2014 06:20:29 +0000 (11:50 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 30 Jan 2014 06:20:29 +0000 (11:50 +0530)
src/lib/asiolink/dummy_io_cb.h

index 79d087d221e158601b3a9e754b9e93007d989230..71d3a4ca70db085e0883fb9239247810cf597c7b 100644 (file)
 #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");
     }
 };