Closed nqf closed 2 years ago
When I start the redis service , future will not return
Redis is killed, and redis-plus-plus cannot connect to it. So when you try to get the result, i.e. auto opt = fut.get()
, it throws exception. That's how std::future
, and boost::future
works, i.e. use exception to indicate error.
You can modify your code as follows to see how it works:
try {
auto opt = fut.get();
// other code
} catch (...) {
cout << "got exception" << endl;
}
Regards
Thanks