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) {
|
if (eptr) {
|
||||||
std::rethrow_exception(eptr);
|
std::rethrow_exception(eptr);
|
||||||
}
|
}
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::runtime_error& e) {
|
||||||
std::cerr << "Caught exception \"" << e.what() << "\"\n";
|
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);
|
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()) +
|
throw std::runtime_error("Failed to refresh lease: error code: " + std::to_string(resp.error_code()) +
|
||||||
", message: " + resp.error_message());
|
", message: " + resp.error_message());
|
||||||
}
|
}
|
||||||
if (resp.value().ttl() == -1) {
|
if (resp.value().ttl() == 0) {
|
||||||
throw std::runtime_error("Failed to refresh lease due to expiration: the new TTL is -1.");
|
throw std::out_of_range("Failed to refresh lease due to expiration: the new TTL is 0.");
|
||||||
}
|
}
|
||||||
// trigger the next round;
|
// trigger the next round;
|
||||||
this->refresh();
|
this->refresh();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue