Skip to content

Commit e1e9b30

Browse files
decompressors now throw TCodeLineException
1 parent 998a1ac commit e1e9b30

File tree

8 files changed

+38
-30
lines changed

8 files changed

+38
-30
lines changed

ydb/library/yql/providers/common/mkql/parser.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ TRuntimeNode BuildParseCall(
267267
return ctx.ProgramBuilder.Apply(
268268
ctx.ProgramBuilder.Udf("Yson2.ConvertTo", {}, userType),
269269
{dom});
270-
} catch(const yexception& ex) {
271-
auto errorEx = TErrorException(TIssuesIds::KIKIMR_BAD_REQUEST);
272-
errorEx.Append(ex.what());
273-
throw errorEx;
270+
} catch (const yexception& ex) {
271+
throw TErrorException(TIssuesIds::KIKIMR_BAD_REQUEST) << ex.what();
274272
}
275273
};
276274

ydb/library/yql/providers/s3/actors/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ PEERDIR(
4747
ydb/library/yql/public/issue
4848
ydb/library/yql/public/types
4949
ydb/library/yql/udfs/common/clickhouse/client
50+
ydb/library/yql/utils
5051
)
5152

5253
IF (CLANG AND NOT WITH_VALGRIND)

ydb/library/yql/providers/s3/actors/yql_s3_read_actor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include <ydb/library/yql/public/udf/arrow/block_builder.h>
6464
#include <ydb/library/yql/public/udf/arrow/block_reader.h>
6565
#include <ydb/library/yql/public/udf/arrow/util.h>
66+
#include <ydb/library/yql/utils/exceptions.h>
6667
#include <ydb/library/yql/utils/yql_panic.h>
6768
#include <ydb/library/yql/parser/pg_wrapper/interface/arrow.h>
6869

@@ -1152,7 +1153,10 @@ class TS3ReadCoroImpl : public TActorCoroImpl {
11521153
Issues.AddIssue(TIssue(ex.message()));
11531154
FatalCode = NYql::NDqProto::StatusIds::BAD_REQUEST;
11541155
RetryStuff->Cancel();
1155-
} catch (const yexception& ex) {
1156+
} catch (const TCodeLineException& ex) {
1157+
if (ex.Code != TIssuesIds::KIKIMR_BAD_REQUEST) {
1158+
throw ex;
1159+
}
11561160
Issues.AddIssue(ExceptionToIssue(ex));
11571161
FatalCode = NYql::NDqProto::StatusIds::BAD_REQUEST;
11581162
RetryStuff->Cancel();

ydb/library/yql/providers/s3/compressors/brotli.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "output_queue_impl.h"
33

44
#include <util/generic/size_literals.h>
5+
#include <ydb/library/yql/utils/exceptions.h>
56
#include <ydb/library/yql/utils/yql_panic.h>
67
#include <contrib/libs/brotli/include/brotli/encode.h>
78

@@ -71,7 +72,7 @@ bool TReadBuffer::nextImpl() {
7172
SubstreamFinished_ = true;
7273
break;
7374
case BROTLI_DECODER_RESULT_ERROR:
74-
ythrow yexception() << "Brotli decoder failed to decompress buffer: "
75+
ythrow TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Brotli decoder failed to decompress buffer: "
7576
<< BrotliDecoderErrorString(BrotliDecoderGetErrorCode(DecoderState_));
7677
case BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:
7778
YQL_ENSURE(availableOut != OutBuffer.size(), "Buffer passed to read in Brotli decoder is too small");
@@ -83,7 +84,7 @@ bool TReadBuffer::nextImpl() {
8384
} while (!decompressedSize && result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT && !InputExhausted_);
8485

8586
if (!SubstreamFinished_ && !decompressedSize) {
86-
ythrow yexception() << "Input stream is incomplete";
87+
ythrow TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Input stream is incomplete";
8788
}
8889

8990
if (decompressedSize > 0)
@@ -97,7 +98,7 @@ bool TReadBuffer::nextImpl() {
9798
void TReadBuffer::InitDecoder() {
9899
DecoderState_ = BrotliDecoderCreateInstance(&TAllocator::Allocate, &TAllocator::Deallocate, nullptr);
99100
if (!DecoderState_) {
100-
ythrow yexception() << "Brotli decoder initialization failed";
101+
ythrow TCodeLineException(TIssuesIds::UNEXPECTED) << "Brotli decoder initialization failed";
101102
}
102103
}
103104

ydb/library/yql/providers/s3/compressors/bzip2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "bzip2.h"
22

33
#include <util/generic/size_literals.h>
4+
#include <ydb/library/yql/utils/exceptions.h>
45
#include <ydb/library/yql/utils/yql_panic.h>
56
#include "output_queue_impl.h"
67

@@ -57,7 +58,7 @@ bool TReadBuffer::nextImpl() {
5758

5859
break;
5960
default:
60-
ythrow yexception() << "Bzip error: " << code;
61+
ythrow TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Bzip error: " << code;
6162
}
6263
}
6364
}

ydb/library/yql/providers/s3/compressors/gz.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "gz.h"
22

33
#include <util/generic/size_literals.h>
4+
#include <ydb/library/yql/utils/exceptions.h>
45
#include <ydb/library/yql/utils/yql_panic.h>
56
#include "output_queue_impl.h"
67

@@ -46,7 +47,7 @@ bool TReadBuffer::nextImpl() {
4647

4748
switch (const auto code = inflate(&Z_, Z_SYNC_FLUSH)) {
4849
case Z_NEED_DICT:
49-
ythrow yexception() << "Need dict.";
50+
ythrow TCodeLineException(TIssuesIds::UNEXPECTED) << "Need dict.";
5051
case Z_STREAM_END:
5152
YQL_ENSURE(inflateReset(&Z_) == Z_OK, "Inflate reset error: " << GetErrMsg(Z_));
5253
[[fallthrough]];
@@ -57,7 +58,7 @@ bool TReadBuffer::nextImpl() {
5758
}
5859
break;
5960
default:
60-
ythrow yexception() << GetErrMsg(Z_) << ", code: " << code;
61+
ythrow TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << GetErrMsg(Z_) << ", code: " << code;
6162
}
6263
}
6364
}

ydb/library/yql/providers/s3/compressors/xz.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "xz.h"
22

33
#include <util/generic/size_literals.h>
4+
#include <ydb/library/yql/utils/exceptions.h>
45
#include <ydb/library/yql/utils/yql_panic.h>
56
#include "output_queue_impl.h"
67

@@ -18,11 +19,11 @@ TReadBuffer::TReadBuffer(NDB::ReadBuffer& source)
1819
case LZMA_OK:
1920
return;
2021
case LZMA_MEM_ERROR:
21-
throw yexception() << "Memory allocation failed.";
22+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Memory allocation failed.";
2223
case LZMA_OPTIONS_ERROR:
23-
throw yexception() << "Unsupported decompressor flags.";
24+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Unsupported decompressor flags.";
2425
default:
25-
throw yexception() << "Unknown error << " << int(ret) << ", possibly a bug.";
26+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Unknown error << " << int(ret) << ", possibly a bug.";
2627
}
2728
}
2829

@@ -70,17 +71,17 @@ bool TReadBuffer::nextImpl() {
7071
case LZMA_OK:
7172
continue;
7273
case LZMA_MEM_ERROR:
73-
throw yexception() << "Memory allocation failed.";
74+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Memory allocation failed.";
7475
case LZMA_FORMAT_ERROR:
75-
throw yexception() << "The input is not in the .xz format.";
76+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "The input is not in the .xz format.";
7677
case LZMA_OPTIONS_ERROR:
77-
throw yexception() << "Unsupported compression options.";
78+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Unsupported compression options.";
7879
case LZMA_DATA_ERROR:
79-
throw yexception() << "Compressed file is corrupt.";
80+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Compressed file is corrupt.";
8081
case LZMA_BUF_ERROR:
81-
throw yexception() << "Compressed file is truncated or otherwise corrupt.";
82+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Compressed file is truncated or otherwise corrupt.";
8283
default:
83-
throw yexception() << "Unknown error " << int(ret) << ", possibly a bug.";
84+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Unknown error " << int(ret) << ", possibly a bug.";
8485
}
8586
}
8687
}
@@ -95,7 +96,7 @@ class TCompressor : public TOutputQueue<> {
9596
// options for further compression
9697
lzma_options_lzma opt_lzma2;
9798
if (lzma_lzma_preset(&opt_lzma2, level))
98-
throw yexception() << "lzma preset failed: lzma version: " << LZMA_VERSION_STRING;
99+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "lzma preset failed: lzma version: " << LZMA_VERSION_STRING;
99100

100101
lzma_filter filters[] = {
101102
{.id = LZMA_FILTER_X86, .options = nullptr},
@@ -107,11 +108,11 @@ class TCompressor : public TOutputQueue<> {
107108
case LZMA_OK:
108109
return;
109110
case LZMA_MEM_ERROR:
110-
throw yexception() << "Memory allocation failed.";
111+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Memory allocation failed.";
111112
case LZMA_OPTIONS_ERROR:
112-
throw yexception() << "Unsupported decompressor flags.";
113+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Unsupported decompressor flags.";
113114
default:
114-
throw yexception() << "Unknown error << " << int(ret) << ", possibly a bug.";
115+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Unknown error << " << int(ret) << ", possibly a bug.";
115116
}
116117
}
117118

@@ -168,17 +169,17 @@ class TCompressor : public TOutputQueue<> {
168169
case LZMA_STREAM_END:
169170
return TOutputQueue::Seal();
170171
case LZMA_MEM_ERROR:
171-
throw yexception() << "Memory allocation failed.";
172+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Memory allocation failed.";
172173
case LZMA_FORMAT_ERROR:
173-
throw yexception() << "The input is not in the .xz format.";
174+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "The input is not in the .xz format.";
174175
case LZMA_OPTIONS_ERROR:
175-
throw yexception() << "Unsupported compression options.";
176+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Unsupported compression options.";
176177
case LZMA_DATA_ERROR:
177-
throw yexception() << "Compressed file is corrupt.";
178+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Compressed file is corrupt.";
178179
case LZMA_BUF_ERROR:
179-
throw yexception() << "Compressed file is truncated or otherwise corrupt.";
180+
throw TCodeLineException(TIssuesIds::KIKIMR_BAD_REQUEST) << "Compressed file is truncated or otherwise corrupt.";
180181
default:
181-
throw yexception() << "Unknown error " << int(ret) << ", possibly a bug.";
182+
throw TCodeLineException(TIssuesIds::UNEXPECTED) << "Unknown error " << int(ret) << ", possibly a bug.";
182183
}
183184
};
184185
}

ydb/library/yql/providers/s3/compressors/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PEERDIR(
88
contrib/libs/lzma
99
contrib/libs/zstd
1010
ydb/library/yql/udfs/common/clickhouse/client
11+
ydb/library/yql/utils
1112
)
1213

1314
ADDINCL(

0 commit comments

Comments
 (0)