Simpler ClientJson::send.

GitOrigin-RevId: 5f992052b2ac11385caee32d7dacc799036170cf
This commit is contained in:
levlam 2018-05-20 02:56:41 +03:00
parent 68dd5cece9
commit 82df6d7625

View File

@ -67,13 +67,13 @@ CSlice ClientJson::store_string(std::string str) {
}
void ClientJson::send(Slice request) {
auto status = [&] {
TRY_RESULT(client_request, to_request(request));
client_.send(std::move(client_request));
return Status::OK();
}();
auto r_request = to_request(request);
if (r_request.is_error()) {
LOG(ERROR) << "Failed to parse " << tag("request", format::escaped(request)) << " " << r_request.error();
return;
}
LOG_IF(ERROR, status.is_error()) << "Failed to parse " << tag("request", format::escaped(request)) << " " << status;
client_.send(r_request.move_as_ok());
}
CSlice ClientJson::receive(double timeout) {