C++ YT Wrapper
C++ library for working with YT clusters
Loading...
Searching...
No Matches
errors.h
Go to the documentation of this file.
1#pragma once
2
7
8#include "fwd.h"
9
10#include <library/cpp/yson/node/node.h>
11
12#include <util/generic/yexception.h>
13#include <util/generic/guid.h>
14#include <util/generic/string.h>
15#include <util/generic/vector.h>
16#include <util/generic/yexception.h>
17
18namespace NJson {
19 class TJsonValue;
20} // namespace NJson
21
22namespace NYT {
23
25
31 : public TWithBackTrace<yexception>
32{ };
33
40 : public yexception
41{ };
42
44
62{
63public:
66
68 explicit TYtError(const TString& message);
69
71 TYtError(int code, TString message, TVector<TYtError> inner = {}, TNode::TMapType attributes = {});
72
74 TYtError(const ::NJson::TJsonValue& value);
75
77 TYtError(const TNode& value);
78
83 bool ContainsErrorCode(int code) const;
84
92 TString ShortDescription() const;
93
99 TString FullDescription() const;
100
106 int GetCode() const;
107
114 const TString& GetMessage() const;
115
122 bool ContainsText(const TStringBuf& text) const;
123
125 const TVector<TYtError>& InnerErrors() const;
126
128 void ParseFrom(TStringBuf jsonError);
129
131 TSet<int> GetAllErrorCodes() const;
132
134 bool HasAttributes() const;
135
137 const TNode::TMapType& GetAttributes() const;
138
140 TString GetYsonText() const;
141
142private:
143 int Code_;
144 TString Message_;
145 TVector<TYtError> InnerErrors_;
146 TNode::TMapType Attributes_;
147};
148
150
156class TErrorResponse
157 : public yexception
158{
159public:
160 TErrorResponse(TYtError error, const TString& requestId);
161
163 const TYtError& GetError() const;
164
166 TString GetRequestId() const;
167
169 bool IsFromTrailers() const;
170
172 bool IsTransportError() const;
173
175 bool IsResolveError() const;
176
178 bool IsAccessDenied() const;
179
181 bool IsUnauthorized() const;
182
185
188
189 // YT can't serve request because it is overloaded.
190 bool IsRequestQueueSizeLimitExceeded() const;
191
193 bool IsChunkUnavailable() const;
194
196 bool IsRequestTimedOut() const;
197
200
201 // User reached their limit of concurrently running operations.
202 bool IsConcurrentOperationsLimitReached() const;
203
205 bool IsOk() const;
206
207 void SetRawError(const TString& message);
208 void SetError(TYtError error);
209 void ParseFromJsonError(const TString& jsonError);
210 void SetIsFromTrailers(bool isFromTrailers);
211
212private:
213 void Setup();
214
215private:
216 TString RequestId_;
217 TYtError Error_;
218 bool IsFromTrailers_ = false;
219};
220
222
227{
229 TJobId JobId;
230
233
240 TString Stderr;
241};
242
244
252class TOperationFailedError
253 : public yexception
254{
255public:
263
264public:
265 TOperationFailedError(EState state, TOperationId id, TYtError ytError, TVector<TFailedJobInfo> failedJobInfo);
266
269
271 TOperationId GetOperationId() const;
272
274 const TYtError& GetError() const;
275
277 const TVector<TFailedJobInfo>& GetFailedJobInfo() const;
278
279private:
280 EState State_;
281 TOperationId OperationId_;
282 TYtError Error_;
283 TVector<TFailedJobInfo> FailedJobInfo_;
284};
285
290 : public yexception
291{ };
292
294
295} // namespace NYT
Error that is thrown when library detects invalid usage of API.
Definition errors.h:32
bool IsAccessDenied() const
Check if error was caused by lack of permissions to execute request.
bool IsChunkUnavailable() const
Check if error was caused by failure to get chunk. Such errors are almost always temporary.
bool IsRequestTimedOut() const
Check if error was caused by internal YT timeout.
bool IsFromTrailers() const
Is error parsed from response trailers.
bool IsResolveError() const
Check if error was caused by failure to resolve cypress path.
const TYtError & GetError() const
Get error object returned by server.
bool IsTransportError() const
Check if error was caused by transport problems inside YT cluster.
bool IsNoSuchTransaction() const
Check if error was caused by trying to work with transaction that was finished or never existed.
bool IsOk() const
bool IsUnauthorized() const
Check if error was caused by authorization issues.
bool IsRequestRateLimitExceeded() const
Check if error was caused by request quota limit exceeding.
TString GetRequestId() const
Get if (correlation-id) of request that was responded with error.
bool IsConcurrentTransactionLockConflict() const
Check if error was caused by failure to lock object because of another transaction is holding lock.
Error that is thrown when trying to read from aborted reader.
Definition errors.h:291
Error that is thrown when operation watched by library fails.
Definition errors.h:254
const TYtError & GetError() const
Return operation error.
TOperationId GetOperationId() const
Get operation id.
const TVector< TFailedJobInfo > & GetFailedJobInfo() const
Return info about failed jobs (if any).
EState
Final state of operation.
Definition errors.h:257
@ Failed
Operation was failed due to some error.
Definition errors.h:259
@ Aborted
Operation didn't experienced errors, but was aborted by user request or by YT.
Definition errors.h:261
EState GetState() const
Get final state of operation.
Error that is thrown when request retries continues for too long.
Definition errors.h:41
Error returned by YT cluster.
Definition errors.h:62
TString ShortDescription() const
Get short description of error.
TYtError(const TString &message)
Constructs error with NYT::NClusterErrorCodes::Generic code and given message.
TString FullDescription() const
Get full description of error.
const TString & GetMessage() const
Get error text of the topmost error.
bool ContainsText(const TStringBuf &text) const
Check if error or any of inner errors contains given text chunk.
const TNode::TMapType & GetAttributes() const
Get error attributes.
bool HasAttributes() const
Check if error has any attributes.
TString GetYsonText() const
Get text yson representation of error.
TYtError()
Constructs error with NYT::NClusterErrorCodes::OK code and empty message.
int GetCode() const
Get error code of the topmost error.
TYtError(const ::NJson::TJsonValue &value)
Construct error from json representation.
TSet< int > GetAllErrorCodes() const
Collect error codes from entire error tree.
TYtError(int code, TString message, TVector< TYtError > inner={}, TNode::TMapType attributes={})
Constructs error from given parameters.
TYtError(const TNode &value)
Construct error from TNode representation.
void ParseFrom(TStringBuf jsonError)
Parse error from json string.
const TVector< TYtError > & InnerErrors() const
Get inner errors.
bool ContainsErrorCode(int code) const
Check if error or any of inner errors has given error code.
Main namespace of YT client.
Definition abortable_stream.h:7
Definition errors.h:227
TJobId JobId
Id of a job.
Definition errors.h:229
TYtError Error
Error describing job failure.
Definition errors.h:232
TString Stderr
Definition errors.h:240