Skip to content

Commit 97f04d7

Browse files
hiddenpathblinkov
authored andcommitted
YT-23616: Implement generic errors extending method
commit_hash:931d1114b30ea24bb1dcf9d2b4cece06f4467498
1 parent 3edbb9e commit 97f04d7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

yt/cpp/mapreduce/http/helpers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ void LogRequest(const THttpHeader& header, const TString& url, bool includeParam
100100
GetLoggedAttributes(header, url, includeParameters, Max<size_t>()));
101101
}
102102

103+
void ExtendGenericError(TErrorResponse& errorResponse, int code, TString message)
104+
{
105+
const auto& error = errorResponse.GetError();
106+
107+
auto inner = error.InnerErrors();
108+
inner.emplace_back(code, std::move(message));
109+
110+
errorResponse.SetError(TYtError(error.GetCode(), error.GetMessage(), std::move(inner), error.GetAttributes()));
111+
}
112+
103113
////////////////////////////////////////////////////////////////////////////////
104114

105115
} // namespace NYT

yt/cpp/mapreduce/http/helpers.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ TString GetLoggedAttributes(const THttpHeader& header, const TString& url, bool
2424

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

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

2935
} // namespace NYT

0 commit comments

Comments
 (0)