|
5 | 5 | using Ydb.Scheme.V1; |
6 | 6 | using Ydb.Sdk.Ado.Schema; |
7 | 7 | using Ydb.Sdk.Services.Table; |
8 | | -using Ydb.Table; |
9 | 8 |
|
10 | 9 | namespace Ydb.Sdk.Ado; |
11 | 10 |
|
@@ -63,24 +62,13 @@ public static async Task<YdbTable> DescribeTable( |
63 | 62 | var describeResponse = await ydbConnection.Session |
64 | 63 | .DescribeTable(WithSuffix(ydbConnection.Database) + tableName, describeTableSettings); |
65 | 64 |
|
66 | | - var status = Status.FromProto(describeResponse.Operation.Status, describeResponse.Operation.Issues); |
67 | | - |
68 | | - if (status.IsNotSuccess) |
69 | | - { |
70 | | - ydbConnection.OnStatus(status); |
71 | | - |
72 | | - throw new YdbException(status); |
73 | | - } |
74 | | - |
75 | | - var describeRes = describeResponse.Operation.Result.Unpack<DescribeTableResult>(); |
76 | | - |
77 | | - return new YdbTable(tableName, describeRes); |
| 65 | + return new YdbTable(tableName, describeResponse); |
78 | 66 | } |
79 | | - catch (Driver.TransportException e) |
| 67 | + catch (YdbException e) |
80 | 68 | { |
81 | | - ydbConnection.OnStatus(e.Status); |
| 69 | + ydbConnection.OnNotSuccessStatusCode(e.Code); |
82 | 70 |
|
83 | | - throw new YdbException(e); |
| 71 | + throw; |
84 | 72 | } |
85 | 73 | } |
86 | 74 |
|
@@ -253,19 +241,31 @@ private static async Task AppendDescribeTable( |
253 | 241 | string? tableType, |
254 | 242 | Action<YdbTable, string> appendInTable) |
255 | 243 | { |
256 | | - var ydbTable = await DescribeTable(ydbConnection, tableName, describeTableSettings); |
257 | | - var type = ydbTable.IsSystem |
258 | | - ? "SYSTEM_TABLE" |
259 | | - : ydbTable.Type switch |
| 244 | + try |
| 245 | + { |
| 246 | + var describeResponse = await ydbConnection.Session |
| 247 | + .DescribeTable(WithSuffix(ydbConnection.Database) + tableName, describeTableSettings); |
| 248 | + var ydbTable = new YdbTable(tableName, describeResponse); |
| 249 | + |
| 250 | + var type = ydbTable.IsSystem |
| 251 | + ? "SYSTEM_TABLE" |
| 252 | + : ydbTable.Type switch |
| 253 | + { |
| 254 | + YdbTable.TableType.Table => "TABLE", |
| 255 | + YdbTable.TableType.ColumnTable => "COLUMN_TABLE", |
| 256 | + YdbTable.TableType.ExternalTable => "EXTERNAL_TABLE", |
| 257 | + _ => throw new ArgumentOutOfRangeException(nameof(tableType)) |
| 258 | + }; |
| 259 | + if (type.IsPattern(tableType)) |
260 | 260 | { |
261 | | - YdbTable.TableType.Table => "TABLE", |
262 | | - YdbTable.TableType.ColumnTable => "COLUMN_TABLE", |
263 | | - YdbTable.TableType.ExternalTable => "EXTERNAL_TABLE", |
264 | | - _ => throw new ArgumentOutOfRangeException(nameof(tableType)) |
265 | | - }; |
266 | | - if (type.IsPattern(tableType)) |
| 261 | + appendInTable(ydbTable, type); |
| 262 | + } |
| 263 | + } |
| 264 | + catch (YdbException e) |
267 | 265 | { |
268 | | - appendInTable(ydbTable, type); |
| 266 | + ydbConnection.OnNotSuccessStatusCode(e.Code); |
| 267 | + |
| 268 | + throw; |
269 | 269 | } |
270 | 270 | } |
271 | 271 |
|
@@ -417,7 +417,7 @@ CancellationToken cancellationToken |
417 | 417 |
|
418 | 418 | if (status.IsNotSuccess) |
419 | 419 | { |
420 | | - throw new YdbException(status); |
| 420 | + throw YdbException.FromServer(operation.Status, operation.Issues); |
421 | 421 | } |
422 | 422 |
|
423 | 423 | foreach (var entry in operation.Result.Unpack<ListDirectoryResult>().Children) |
@@ -461,9 +461,11 @@ await SchemaObjects( |
461 | 461 |
|
462 | 462 | return ydbSchemaObjects; |
463 | 463 | } |
464 | | - catch (Driver.TransportException e) |
| 464 | + catch (YdbException e) |
465 | 465 | { |
466 | | - throw new YdbException(e); |
| 466 | + ydbConnection.OnNotSuccessStatusCode(e.Code); |
| 467 | + |
| 468 | + throw; |
467 | 469 | } |
468 | 470 | } |
469 | 471 |
|
|
0 commit comments