diff options
author | ulanovgeorgiy <ulanovgeorgiy@yandex-team.com> | 2023-02-02 15:45:06 +0300 |
---|---|---|
committer | ulanovgeorgiy <ulanovgeorgiy@yandex-team.com> | 2023-02-02 15:45:06 +0300 |
commit | 4676a64273b09b50f84bd7bc93a1ce598512f136 (patch) | |
tree | e61825a8073060303ddcba6658d6a13b90f85055 /library/cpp/protobuf/util | |
parent | d356fcb037bfbba8740bde2db0f51a8b4aaa9128 (diff) | |
download | ydb-4676a64273b09b50f84bd7bc93a1ce598512f136.tar.gz |
enabling writing error message to exception in the default
Diffstat (limited to 'library/cpp/protobuf/util')
-rw-r--r-- | library/cpp/protobuf/util/pb_io.cpp | 4 | ||||
-rw-r--r-- | library/cpp/protobuf/util/pb_io.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 3ec95f0a9b..92f3675b53 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -180,7 +180,7 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, NProtoBuf::TextFormat::Parser p; ConfigureParser(options, p); - bool writeErrorToException = options & EParseFromTextFormatOption::WriteErrorMessageToException; + bool writeErrorToException = !(options & EParseFromTextFormatOption::ForceWriteParsingErrorsToCerr); TStringStream errorLog; THolder<TErrorCollector> errorCollector; @@ -195,7 +195,7 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, if (!p.Parse(&adaptor, &m)) { // remove everything that may have been read m.Clear(); - if (Y_UNLIKELY(writeErrorToException)) { + if (Y_LIKELY(writeErrorToException)) { ythrow yexception() << errorLog.Str(); } else { ythrow yexception() << "ParseFromTextFormat failed on Parse for " << m.GetTypeName(); diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 04c6ebb305..e10cee8a37 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -59,8 +59,8 @@ void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& enum class EParseFromTextFormatOption : ui64 { // Unknown fields will be ignored by the parser AllowUnknownField = 1, - // Error message will be writen to exception message instead of cerr - WriteErrorMessageToException = 2 + // Error message will be will be written to stderr in the original format + ForceWriteParsingErrorsToCerr = 2 }; Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); |