diff options
| author | hiddenpath <[email protected]> | 2025-02-18 12:34:23 +0300 |
|---|---|---|
| committer | hiddenpath <[email protected]> | 2025-02-18 13:18:25 +0300 |
| commit | b8ac60a673bd416577ca37b911409acbd32c7be2 (patch) | |
| tree | c7a831e31968ebea4fbcdcb60fcd406193f208f5 /yt/cpp/mapreduce/http/http_client.cpp | |
| parent | 75f5993689410f06224ace8767c11e2c71093fde (diff) | |
YT-23616: Remove HttpCode from TErrorResponse
commit_hash:412a7a1e02eb68d388aff73a439e98f6f2dab8a6
Diffstat (limited to 'yt/cpp/mapreduce/http/http_client.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/http/http_client.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/yt/cpp/mapreduce/http/http_client.cpp b/yt/cpp/mapreduce/http/http_client.cpp index 34be58daab6..b22fcacb164 100644 --- a/yt/cpp/mapreduce/http/http_client.cpp +++ b/yt/cpp/mapreduce/http/http_client.cpp @@ -41,25 +41,21 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& return {}; } - TErrorResponse errorResponse(static_cast<int>(httpCode), requestId); - auto logAndSetError = [&] (int code, const TString& rawError) { YT_LOG_ERROR("RSP %v - HTTP %v - %v", requestId, httpCode, rawError.data()); - errorResponse.SetError(TYtError(code, rawError)); + return TErrorResponse(TYtError(code, rawError), requestId); }; switch (httpCode) { case NHttp::EStatusCode::TooManyRequests: - logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); - break; + return logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); case NHttp::EStatusCode::InternalServerError: - logAndSetError(NClusterErrorCodes::NRpc::Unavailable, "internal error in proxy " + hostName); - break; + return logAndSetError(NClusterErrorCodes::NRpc::Unavailable, "internal error in proxy " + hostName); default: { TStringStream httpHeaders; @@ -78,7 +74,10 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& errorString.data()); if (auto errorHeader = response->GetHeaders()->Find("X-YT-Error")) { - errorResponse.ParseFromJsonError(*errorHeader); + TYtError error; + error.ParseFrom(*errorHeader); + + TErrorResponse errorResponse(std::move(error), requestId); if (errorResponse.IsOk()) { return Nothing(); } @@ -88,13 +87,9 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& return errorResponse; } - errorResponse.SetRawError( - errorString + " - X-YT-Error is missing in headers"); - break; + return TErrorResponse(TYtError(errorString + " - X-YT-Error is missing in headers"), requestId); } } - - return errorResponse; } void CheckErrorResponse(const TString& hostName, const TString& requestId, const NHttp::IResponsePtr& response) @@ -317,8 +312,9 @@ private: TMaybe<TErrorResponse> ParseError(const NHttp::THeadersPtr& headers) { if (auto errorHeader = headers->Find("X-YT-Error")) { - TErrorResponse errorResponse(static_cast<int>(Response_->GetStatusCode()), RequestId_); - errorResponse.ParseFromJsonError(*errorHeader); + TYtError error; + error.ParseFrom(*errorHeader); + TErrorResponse errorResponse(std::move(error), RequestId_); if (errorResponse.IsOk()) { return Nothing(); } |
