Skip to content
Snippets Groups Projects
Commit 25275150 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Improve error reporting on invalid RPC arguments

parent 14894bcb
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <memory> #include <memory>
#include <tuple> #include <tuple>
#include <functional> #include <functional>
//#include <iostream> #include <iostream>
namespace ftl { namespace ftl {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <winsock.h> #include <winsock.h>
#endif #endif
#include <iostream>
#include <sstream> #include <sstream>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
......
...@@ -60,8 +60,9 @@ void ftl::net::Dispatcher::dispatch_call(Socket &s, const msgpack::object &msg) ...@@ -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; //std::cout << " RESULT " << result.as<std::string>() << std::endl;
s.send(FTL_PROTOCOL_RPCRETURN, buf.str()); s.send(FTL_PROTOCOL_RPCRETURN, buf.str());
} catch (...) { } catch (int e) {
throw; //throw;
LOG(ERROR) << "Exception when attempting to call RPC (" << e << ")";
} }
} }
} }
...@@ -77,15 +78,13 @@ void ftl::net::Dispatcher::dispatch_notification(Socket &s, msgpack::object cons ...@@ -77,15 +78,13 @@ void ftl::net::Dispatcher::dispatch_notification(Socket &s, msgpack::object cons
auto &&name = std::get<1>(the_call); auto &&name = std::get<1>(the_call);
auto &&args = std::get<2>(the_call); auto &&args = std::get<2>(the_call);
std::cout << "RPC NOTIFY" << name << std::endl;
auto it_func = funcs_.find(name); auto it_func = funcs_.find(name);
if (it_func != end(funcs_)) { if (it_func != end(funcs_)) {
try { try {
auto result = (it_func->second)(args); auto result = (it_func->second)(args);
} catch (...) { } catch (int e) {
throw; throw e;
} }
} }
} }
...@@ -93,14 +92,15 @@ void ftl::net::Dispatcher::dispatch_notification(Socket &s, msgpack::object cons ...@@ -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, void ftl::net::Dispatcher::enforce_arg_count(std::string const &func, std::size_t found,
std::size_t expected) { std::size_t expected) {
if (found != 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) { void ftl::net::Dispatcher::enforce_unique_name(std::string const &func) {
auto pos = funcs_.find(func); auto pos = funcs_.find(func);
if (pos != end(funcs_)) { if (pos != end(funcs_)) {
throw; throw -1;
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <ftl/net/socket.hpp> #include <ftl/net/socket.hpp>
#include <ftl/net/protocol.hpp> #include <ftl/net/protocol.hpp>
#include <functional> #include <functional>
#include <iostream>
using ftl::net::Socket; using ftl::net::Socket;
using ftl::net::Protocol; using ftl::net::Protocol;
......
...@@ -396,7 +396,6 @@ int Socket::_send() { ...@@ -396,7 +396,6 @@ int Socket::_send() {
} }
Socket::~Socket() { Socket::~Socket() {
std::cerr << "DESTROYING SOCKET" << std::endl;
close(); close();
// Delete socket buffer // Delete socket buffer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment