aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/interface
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-11-19 10:54:24 +0300
committerermolovd <ermolovd@yandex-team.com>2024-11-19 11:06:45 +0300
commit7be946f684e606f5baa9e3a13401cc19b8ac9a3b (patch)
treea4d6ce2a580ba953a048a64bdedbda1f6c7a1d26 /yt/cpp/mapreduce/interface
parent907667c6ffd6222845fe8e18fd548e508250b5d0 (diff)
downloadydb-7be946f684e606f5baa9e3a13401cc19b8ac9a3b.tar.gz
YT-22943: add context for system errors
* thrown system errors contain context (i.e. host method and request id that produced error) Type: feature Component: cpp-sdk commit_hash:af72a3a37785e9e373e816c2cc072df2076f821d
Diffstat (limited to 'yt/cpp/mapreduce/interface')
-rw-r--r--yt/cpp/mapreduce/interface/errors.cpp24
-rw-r--r--yt/cpp/mapreduce/interface/errors.h19
2 files changed, 25 insertions, 18 deletions
diff --git a/yt/cpp/mapreduce/interface/errors.cpp b/yt/cpp/mapreduce/interface/errors.cpp
index ef3d2db4a3..0819c8ca56 100644
--- a/yt/cpp/mapreduce/interface/errors.cpp
+++ b/yt/cpp/mapreduce/interface/errors.cpp
@@ -20,20 +20,11 @@ using namespace NJson;
static void WriteErrorDescription(const TYtError& error, IOutputStream* out)
{
- (*out) << '\'' << error.GetMessage() << '\'';
+ (*out) << error.GetMessage();
const auto& innerErrorList = error.InnerErrors();
if (!innerErrorList.empty()) {
- (*out) << " { ";
- bool first = true;
- for (const auto& innerError : innerErrorList) {
- if (first) {
- first = false;
- } else {
- (*out) << " ; ";
- }
- WriteErrorDescription(innerError, out);
- }
- (*out) << " }";
+ (*out) << ": ";
+ WriteErrorDescription(innerErrorList[0], out);
}
}
@@ -118,9 +109,11 @@ TYtError::TYtError(const TString& message)
, Message_(message)
{ }
-TYtError::TYtError(int code, const TString& message)
+TYtError::TYtError(int code, TString message, TVector<TYtError> innerError, TNode::TMapType attributes)
: Code_(code)
, Message_(message)
+ , InnerErrors_(innerError)
+ , Attributes_(attributes)
{ }
TYtError::TYtError(const TJsonValue& value)
@@ -396,6 +389,11 @@ void TErrorResponse::Setup()
*this << Error_.FullDescription();
}
+TTransportError::TTransportError(TYtError error)
+{
+ *this << error.FullDescription();
+}
+
////////////////////////////////////////////////////////////////////////////////
TOperationFailedError::TOperationFailedError(
diff --git a/yt/cpp/mapreduce/interface/errors.h b/yt/cpp/mapreduce/interface/errors.h
index afad58ed72..1311dbcf3d 100644
--- a/yt/cpp/mapreduce/interface/errors.h
+++ b/yt/cpp/mapreduce/interface/errors.h
@@ -6,14 +6,14 @@
/// Errors and exceptions emitted by library.
#include "fwd.h"
-#include "common.h"
#include <library/cpp/yson/node/node.h>
#include <util/generic/bt_exception.h>
-#include <util/generic/yexception.h>
+#include <util/generic/guid.h>
#include <util/generic/string.h>
#include <util/generic/vector.h>
+#include <util/generic/yexception.h>
namespace NJson {
class TJsonValue;
@@ -67,8 +67,8 @@ public:
/// Constructs error with NYT::NClusterErrorCodes::Generic code and given message.
explicit TYtError(const TString& message);
- /// Constructs error with given code and given message.
- TYtError(int code, const TString& message);
+ /// Constructs error from given parameters.
+ TYtError(int code, TString message, TVector<TYtError> inner = {}, TNode::TMapType attributes = {});
/// Construct error from json representation.
TYtError(const ::NJson::TJsonValue& value);
@@ -158,7 +158,6 @@ class TErrorResponse
{
public:
TErrorResponse(int httpCode, const TString& requestId);
- TErrorResponse(int httpCode, TYtError error);
/// Get error object returned by server.
const TYtError& GetError() const;
@@ -222,6 +221,16 @@ private:
////////////////////////////////////////////////////////////////////////////////
+/// @brief System error indicating that response from server cannot be received
+class TTransportError
+ : public yexception
+{
+public:
+ explicit TTransportError(TYtError error);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
/// Info about failed jobs.
///
/// @see NYT::TOperationFailedError