return early on error case for clarity

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0cf892b5772d12b3ca914186c000b18dba912429
This commit is contained in:
Caolán McNamara 2024-05-19 14:20:19 +01:00 committed by Michael Meeks
parent 5075b59955
commit b4490dcb68

View file

@ -1720,8 +1720,16 @@ void ClientRequestDispatcher::handleClientProxyRequest(const Poco::Net::HTTPRequ
auto docBroker = pair.first;
auto errorMsg = pair.second;
if (docBroker)
if (!docBroker)
{
LOG_ERR("Failed to find document [" << docKey << "]: " << errorMsg);
// badness occurred:
auto streamSocket = std::static_pointer_cast<StreamSocket>(disposition.getSocket());
HttpHelper::sendErrorAndShutdown(http::StatusCode::BadRequest, streamSocket);
// FIXME: send docunloading & re-try on client ?
return;
}
// need to move into the DocumentBroker context before doing session lookup / creation etc.
docBroker->setupTransfer(
disposition,
@ -1761,15 +1769,6 @@ void ClientRequestDispatcher::handleClientProxyRequest(const Poco::Net::HTTPRequ
HttpHelper::sendErrorAndShutdown(http::StatusCode::BadRequest, streamSocket);
});
}
else
{
LOG_ERR("Failed to find document [" << docKey << "]: " << errorMsg);
// badness occurred:
auto streamSocket = std::static_pointer_cast<StreamSocket>(disposition.getSocket());
HttpHelper::sendErrorAndShutdown(http::StatusCode::BadRequest, streamSocket);
// FIXME: send docunloading & re-try on client ?
}
}
#endif
void ClientRequestDispatcher::handleClientWsUpgrade(const Poco::Net::HTTPRequest& request,