Skip to content

Commit

Permalink
YT-23616: Implement generic errors extending method
Browse files Browse the repository at this point in the history
commit_hash:931d1114b30ea24bb1dcf9d2b4cece06f4467498
  • Loading branch information
hdnpth committed Feb 16, 2025
1 parent a657513 commit 44db6ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions yt/cpp/mapreduce/http/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void LogRequest(const THttpHeader& header, const TString& url, bool includeParam
GetLoggedAttributes(header, url, includeParameters, Max<size_t>()));
}

void ExtendGenericError(TErrorResponse& errorResponse, int code, TString message)
{
const auto& error = errorResponse.GetError();

auto inner = error.InnerErrors();
inner.emplace_back(code, std::move(message));

errorResponse.SetError(TYtError(error.GetCode(), error.GetMessage(), std::move(inner), error.GetAttributes()));
}

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT
6 changes: 6 additions & 0 deletions yt/cpp/mapreduce/http/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ TString GetLoggedAttributes(const THttpHeader& header, const TString& url, bool

void LogRequest(const THttpHeader& header, const TString& url, bool includeParameters, const TString& requestId, const TString& hostName);

// Sometimes errors may not include any specific inner errors and appear to be generic.
// To differentiate these errors and reduce reliance on HTTP status codes, we need to extend inner error information.
//
// XXX(hiddenpath): Remove this method when server will respond with specific errors.
void ExtendGenericError(TErrorResponse& errorResponse, int code, TString message);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

0 comments on commit 44db6ad

Please sign in to comment.