aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2023-04-20 21:43:20 +0300
committerilnaz <ilnaz@ydb.tech>2023-04-20 21:43:20 +0300
commitd8a762c713b23b525ed3da07dd9726d60e8c5e8a (patch)
treeb9b6dad506c5eca617cbf4a0147b8c421f662009
parent4292032c6870c33f6f7b7941190053d0518dda2c (diff)
downloadydb-d8a762c713b23b525ed3da07dd9726d60e8c5e8a.tar.gz
Rich errors
-rw-r--r--ydb/core/persqueue/writer/writer.cpp50
-rw-r--r--ydb/core/persqueue/writer/writer.h10
-rw-r--r--ydb/core/tx/datashard/change_sender_cdc_stream.cpp6
3 files changed, 48 insertions, 18 deletions
diff --git a/ydb/core/persqueue/writer/writer.cpp b/ydb/core/persqueue/writer/writer.cpp
index bdec00da367..b0298fc4c38 100644
--- a/ydb/core/persqueue/writer/writer.cpp
+++ b/ydb/core/persqueue/writer/writer.cpp
@@ -13,20 +13,29 @@
#include <util/generic/map.h>
#include <util/string/builder.h>
-namespace NKikimr {
-namespace NPQ {
+namespace NKikimr::NPQ {
+
+TString TEvPartitionWriter::TEvInitResult::TSuccess::ToString() const {
+ return TStringBuilder() << "Success {"
+ << " OwnerCookie: " << OwnerCookie
+ << " SourceIdInfo: " << SourceIdInfo.ShortDebugString()
+ << " }";
+}
+
+TString TEvPartitionWriter::TEvInitResult::TError::ToString() const {
+ return TStringBuilder() << "Error {"
+ << " Reason: " << Reason
+ << " Response: " << Response.ShortDebugString()
+ << " }";
+}
TString TEvPartitionWriter::TEvInitResult::ToString() const {
auto out = TStringBuilder() << ToStringHeader() << " {";
if (IsSuccess()) {
- const auto& result = GetResult();
- out << " OwnerCookie: " << result.OwnerCookie
- << " SourceIdInfo: " << result.SourceIdInfo.ShortDebugString();
+ out << " " << GetResult().ToString();
} else {
- const auto& error = GetError();
- out << " Reason: " << error.Reason
- << " Response: " << error.Response.ShortDebugString();
+ out << " " << GetError().ToString();
}
out << " }";
@@ -39,6 +48,28 @@ TString TEvPartitionWriter::TEvWriteAccepted::ToString() const {
<< " }";
}
+TString TEvPartitionWriter::TEvWriteResponse::DumpError() const {
+ Y_VERIFY(!IsSuccess());
+
+ return TStringBuilder() << "Error {"
+ << " Reason: " << GetError().Reason
+ << " Response: " << Record.ShortDebugString()
+ << " }";
+}
+
+TString TEvPartitionWriter::TEvWriteResponse::ToString() const {
+ auto out = TStringBuilder() << ToStringHeader() << " {";
+
+ if (IsSuccess()) {
+ out << " Success { Response: " << Record.ShortDebugString() << " }";
+ } else {
+ out << " " << DumpError();
+ }
+
+ out << " }";
+ return out;
+}
+
class TPartitionWriter: public TActorBootstrapped<TPartitionWriter> {
static void FillHeader(NKikimrClient::TPersQueuePartitionRequest& request,
ui32 partitionId, const TActorId& pipeClient)
@@ -489,5 +520,4 @@ IActor* CreatePartitionWriter(const TActorId& client, ui64 tabletId, ui32 partit
return new TPartitionWriter(client, tabletId, partitionId, sourceId, opts);
}
-} // NPQ
-} // NKikimr
+}
diff --git a/ydb/core/persqueue/writer/writer.h b/ydb/core/persqueue/writer/writer.h
index 5e880bab00b..950758f3022 100644
--- a/ydb/core/persqueue/writer/writer.h
+++ b/ydb/core/persqueue/writer/writer.h
@@ -7,8 +7,7 @@
#include <variant>
-namespace NKikimr {
-namespace NPQ {
+namespace NKikimr::NPQ {
struct TEvPartitionWriter {
enum EEv {
@@ -29,11 +28,13 @@ struct TEvPartitionWriter {
struct TSuccess {
TString OwnerCookie;
TSourceIdInfo SourceIdInfo;
+ TString ToString() const;
};
struct TError {
TString Reason;
NKikimrClient::TResponse Response;
+ TString ToString() const;
};
std::variant<TSuccess, TError> Result;
@@ -100,6 +101,8 @@ struct TEvPartitionWriter {
bool IsSuccess() const { return Result.index() == 0; }
const TError& GetError() const { return std::get<1>(Result); }
+ TString DumpError() const;
+ TString ToString() const override;
};
struct TEvDisconnected: public TEventLocal<TEvDisconnected, EvDisconnected> {
@@ -118,5 +121,4 @@ struct TPartitionWriterOpts {
IActor* CreatePartitionWriter(const TActorId& client, ui64 tabletId, ui32 partitionId, const TString& sourceId,
const TPartitionWriterOpts& opts = {});
-} // NPQ
-} // NKikimr
+}
diff --git a/ydb/core/tx/datashard/change_sender_cdc_stream.cpp b/ydb/core/tx/datashard/change_sender_cdc_stream.cpp
index 75ff27bf95b..f488f7b65e1 100644
--- a/ydb/core/tx/datashard/change_sender_cdc_stream.cpp
+++ b/ydb/core/tx/datashard/change_sender_cdc_stream.cpp
@@ -49,8 +49,7 @@ class TCdcChangeSenderPartition: public TActorBootstrapped<TCdcChangeSenderParti
const auto& result = *ev->Get();
if (!result.IsSuccess()) {
- LOG_E("Error at 'Init'"
- << ": reason# " << result.GetError().Reason);
+ LOG_E("Error at 'Init': " << result.GetError().ToString());
return Leave();
}
@@ -167,8 +166,7 @@ class TCdcChangeSenderPartition: public TActorBootstrapped<TCdcChangeSenderParti
const auto& result = *ev->Get();
if (!result.IsSuccess()) {
- LOG_E("Error at 'Write'"
- << ": reason# " << result.GetError().Reason);
+ LOG_E("Error at 'Write': " << result.DumpError());
return Leave();
}