diff --git a/components/net/cpp/include/ftl/net/peer.hpp b/components/net/cpp/include/ftl/net/peer.hpp index 2c3e1fd636edd16772b3bf44ecb0e15fefa3b16b..976155ac94e323b112306f4fa675512ff3d23aca 100644 --- a/components/net/cpp/include/ftl/net/peer.hpp +++ b/components/net/cpp/include/ftl/net/peer.hpp @@ -6,6 +6,7 @@ #endif #include <ftl/net/common.hpp> +#include <ftl/exception.hpp> //#define GLOG_NO_ABBREVIATED_SEVERITIES #include <loguru.hpp> @@ -343,7 +344,8 @@ R Peer::call(const std::string &name, ARGS... args) { if (!hasreturned) { cancelCall(id); - throw 1; + LOG(ERROR) << "RPC Timeout: " << name; + throw ftl::exception("RPC failed with timeout"); } return result; diff --git a/components/net/cpp/include/ftl/net/universe.hpp b/components/net/cpp/include/ftl/net/universe.hpp index b4419b1f7fc713259b0d9f1a14f00ff12332dd6b..29680c601c19ba37ff20771659ef379ce3511631 100644 --- a/components/net/cpp/include/ftl/net/universe.hpp +++ b/components/net/cpp/include/ftl/net/universe.hpp @@ -378,7 +378,7 @@ R Universe::call(const ftl::UUID &pid, const std::string &name, ARGS... args) { if (p == nullptr || !p->isConnected()) { if (p == nullptr) DLOG(WARNING) << "Attempting to call an unknown peer : " << pid.to_string(); else DLOG(WARNING) << "Attempting to call an disconnected peer : " << pid.to_string(); - throw -1; + throw ftl::exception("Calling disconnected peer"); } return p->call<R>(name, args...); } diff --git a/components/net/cpp/src/dispatcher.cpp b/components/net/cpp/src/dispatcher.cpp index 3231b8ddc4604c7929a04c5c33a36385e1bd94ea..7a5df5091235dc081c0c9e51c199dcca5e7f0f31 100644 --- a/components/net/cpp/src/dispatcher.cpp +++ b/components/net/cpp/src/dispatcher.cpp @@ -2,6 +2,7 @@ #include <loguru.hpp> #include <ftl/net/dispatcher.hpp> #include <ftl/net/peer.hpp> +#include <ftl/exception.hpp> #include <iostream> using ftl::net::Peer; @@ -88,13 +89,6 @@ void ftl::net::Dispatcher::dispatch_call(Peer &s, const msgpack::object &msg) { std::stringstream buf; msgpack::pack(buf, res_obj); s.send("__return__", buf.str());*/ - } catch (int e) { - //throw; - LOG(ERROR) << "Exception when attempting to call RPC (" << e << ")"; - /*response_t res_obj = std::make_tuple(1,id,msgpack::object(e),msgpack::object()); - std::stringstream buf; - msgpack::pack(buf, res_obj); - s.send("__return__", buf.str());*/ } } else { LOG(WARNING) << "No binding found for " << name; @@ -150,7 +144,7 @@ void ftl::net::Dispatcher::enforce_arg_count(std::string const &func, std::size_ std::size_t expected) { if (found != expected) { LOG(FATAL) << "RPC argument missmatch for '" << func << "' - " << found << " != " << expected; - throw -1; + throw ftl::exception("RPC argument missmatch"); } } @@ -158,7 +152,7 @@ void ftl::net::Dispatcher::enforce_unique_name(std::string const &func) { auto pos = funcs_.find(func); if (pos != end(funcs_)) { LOG(FATAL) << "RPC non unique binding for '" << func << "'"; - throw -1; + throw ftl::exception("RPC binding not unique"); } }