diff --git a/net/include/ftl/net/dispatcher.hpp b/net/include/ftl/net/dispatcher.hpp index c358ad10495e5b0790658342fda782b939e6bde5..3d94659911a08806df269e44c3e4ea3cc9c03250 100644 --- a/net/include/ftl/net/dispatcher.hpp +++ b/net/include/ftl/net/dispatcher.hpp @@ -6,7 +6,7 @@ #include <memory> #include <tuple> #include <functional> -//#include <iostream> +#include <iostream> namespace ftl { diff --git a/net/include/ftl/net/socket.hpp b/net/include/ftl/net/socket.hpp index 6b0fc7a31b994ef2d0d6d2f63433988d081871f2..a3efdfc121fed43919fe1f7b89604dfb7bee6813 100644 --- a/net/include/ftl/net/socket.hpp +++ b/net/include/ftl/net/socket.hpp @@ -15,6 +15,7 @@ #include <winsock.h> #endif +#include <iostream> #include <sstream> #include <tuple> #include <vector> diff --git a/net/src/dispatcher.cpp b/net/src/dispatcher.cpp index bc7a842aca41798f4e4f1b7d07c10e82b148ec3e..8bbe3a1b44a76e5d43f37924cd38d3179fcfd5f7 100644 --- a/net/src/dispatcher.cpp +++ b/net/src/dispatcher.cpp @@ -60,8 +60,9 @@ void ftl::net::Dispatcher::dispatch_call(Socket &s, const msgpack::object &msg) //std::cout << " RESULT " << result.as<std::string>() << std::endl; s.send(FTL_PROTOCOL_RPCRETURN, buf.str()); - } catch (...) { - throw; + } catch (int e) { + //throw; + LOG(ERROR) << "Exception when attempting to call RPC (" << e << ")"; } } } @@ -76,16 +77,14 @@ void ftl::net::Dispatcher::dispatch_notification(Socket &s, msgpack::object cons auto &&name = std::get<1>(the_call); auto &&args = std::get<2>(the_call); - - std::cout << "RPC NOTIFY" << name << std::endl; auto it_func = funcs_.find(name); if (it_func != end(funcs_)) { try { auto result = (it_func->second)(args); - } catch (...) { - throw; + } catch (int e) { + throw e; } } } @@ -93,14 +92,15 @@ void ftl::net::Dispatcher::dispatch_notification(Socket &s, msgpack::object cons void ftl::net::Dispatcher::enforce_arg_count(std::string const &func, std::size_t found, std::size_t expected) { if (found != expected) { - throw; + LOG(FATAL) << "RPC argument missmatch - " << found << " != " << expected; + throw -1; } } void ftl::net::Dispatcher::enforce_unique_name(std::string const &func) { auto pos = funcs_.find(func); if (pos != end(funcs_)) { - throw; + throw -1; } } diff --git a/net/src/protocol.cpp b/net/src/protocol.cpp index 59444e69eba844fa7bd3d4edd1445c48e9d20f80..125477376eb68e02defe7c747e829d0b56c27c7c 100644 --- a/net/src/protocol.cpp +++ b/net/src/protocol.cpp @@ -2,6 +2,7 @@ #include <ftl/net/socket.hpp> #include <ftl/net/protocol.hpp> #include <functional> +#include <iostream> using ftl::net::Socket; using ftl::net::Protocol; diff --git a/net/src/socket.cpp b/net/src/socket.cpp index 0eadd46ea0d4f1c68f545fc70b50c6b48face821..94a2909c7e781cbef1c1731299c936a0bad67be9 100644 --- a/net/src/socket.cpp +++ b/net/src/socket.cpp @@ -396,7 +396,6 @@ int Socket::_send() { } Socket::~Socket() { - std::cerr << "DESTROYING SOCKET" << std::endl; close(); // Delete socket buffer