rpc_server/client example error handling

This commit is contained in:
Michael Davidsaver
2024-04-22 07:57:05 -07:00
parent 9b77c061b0
commit d18e2d7e35
2 changed files with 26 additions and 14 deletions
+12 -8
View File
@@ -36,13 +36,17 @@ int main(int argc, char* argv[])
// Create a client context
auto ctxt(client::Context::fromEnv());
auto reply(ctxt.rpc(argv[1])
.arg("lhs", argv[2])
.arg("rhs", argv[3])
.exec()
->wait(5.0));
try {
auto reply(ctxt.rpc(argv[1])
.arg("lhs", argv[2])
.arg("rhs", argv[3])
.exec()
->wait(5.0));
std::cout<<"Reply\n"<<reply;
return 0;
std::cout<<"Reply\n"<<reply;
return 0;
} catch(std::exception& e){
std::cerr<<"Error: "<<e.what()<<"\n";
return 1;
}
}