diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/utils/rpc.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/host/lib/utils/rpc.hpp b/host/lib/utils/rpc.hpp index 17e5fe099..dc6762928 100644 --- a/host/lib/utils/rpc.hpp +++ b/host/lib/utils/rpc.hpp @@ -19,6 +19,9 @@ #define INCLUDED_UTILS_RPC_HPP #include <rpc/client.h> +#include <rpc/rpc_error.h> +#include <uhd/exception.hpp> +#include <boost/format.hpp> namespace uhd { @@ -54,8 +57,20 @@ class rpc_client return_type call(std::string const& func_name, Args&&... args) { std::lock_guard<std::mutex> lock(_mutex); - return _client.call(func_name, std::forward<Args>(args)...) - .template as<return_type>(); + try { + return _client.call(func_name, std::forward<Args>(args)...) + .template as<return_type>(); + } catch (const ::rpc::rpc_error &ex) { + throw uhd::runtime_error(str( + boost::format("Error during RPC call to `%s'. Error message: %s") + % func_name % ex.what() + )); + } catch (const std::bad_cast& ex) { + throw uhd::runtime_error(str( + boost::format("Error during RPC call to `%s'. Error message: %s") + % func_name % ex.what() + )); + } }; /*! Perform an RPC call; also includes a token. |