Change KeepAlive lease expiry to throw std::out_of_range
Update documentation to show different exceptions used by KeepAlive.
This commit is contained in:
parent
3e30c4c61d
commit
8fc7533a76
|
|
@ -540,8 +540,10 @@ is constructed.
|
|||
if (eptr) {
|
||||
std::rethrow_exception(eptr);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
std::cerr << "Caught exception \"" << e.what() << "\"\n";
|
||||
} catch(const std::runtime_error& e) {
|
||||
std::cerr << "Connection failure \"" << e.what() << "\"\n";
|
||||
} catch(const std::out_of_range& e) {
|
||||
std::cerr << "Lease expiry \"" << e.what() << "\"\n";
|
||||
}
|
||||
};
|
||||
etcd::KeepAlive keepalive(etcd, handler, ttl, lease_id);
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ void etcd::KeepAlive::refresh()
|
|||
throw std::runtime_error("Failed to refresh lease: error code: " + std::to_string(resp.error_code()) +
|
||||
", message: " + resp.error_message());
|
||||
}
|
||||
if (resp.value().ttl() == -1) {
|
||||
throw std::runtime_error("Failed to refresh lease due to expiration: the new TTL is -1.");
|
||||
if (resp.value().ttl() == 0) {
|
||||
throw std::out_of_range("Failed to refresh lease due to expiration: the new TTL is 0.");
|
||||
}
|
||||
// trigger the next round;
|
||||
this->refresh();
|
||||
|
|
|
|||
Loading…
Reference in New Issue