Skip to content

Commit 585f468

Browse files
lavrukovAlexander Lavrukov
andauthored
noticket: Sealed schema exceptions
Co-authored-by: Alexander Lavrukov <[email protected]>
1 parent 163a9ad commit 585f468

File tree

14 files changed

+51
-45
lines changed

14 files changed

+51
-45
lines changed

repository-ydb-common/src/main/java/tech/ydb/yoj/repository/ydb/exception/SnapshotCreateException.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

repository-ydb-common/src/main/java/tech/ydb/yoj/repository/ydb/exception/YdbRepositoryException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@SuppressWarnings("checkstyle:LeftCurly")
1111
public sealed class YdbRepositoryException
1212
extends ImplementationSpecificRepositoryException
13-
permits ResultTruncatedException, UnexpectedException, SnapshotCreateException, YdbSchemaException
13+
permits ResultTruncatedException, UnexpectedException
1414
{
1515
public YdbRepositoryException(Object request, Object response) {
1616
this(null, request, response);

repository-ydb-common/src/main/java/tech/ydb/yoj/repository/ydb/exception/YdbSchemaException.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

repository-ydb-common/src/main/java/tech/ydb/yoj/repository/ydb/exception/YdbSchemaPathNotFoundException.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/client/YdbSchemaOperations.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
import tech.ydb.yoj.repository.db.EntitySchema;
3737
import tech.ydb.yoj.repository.db.exception.CreateTableException;
3838
import tech.ydb.yoj.repository.db.exception.DropTableException;
39-
import tech.ydb.yoj.repository.ydb.exception.SnapshotCreateException;
40-
import tech.ydb.yoj.repository.ydb.exception.YdbRepositoryException;
41-
import tech.ydb.yoj.repository.ydb.exception.YdbSchemaPathNotFoundException;
39+
import tech.ydb.yoj.repository.db.exception.GenericSchemaException;
40+
import tech.ydb.yoj.repository.db.exception.PathNotFoundException;
41+
import tech.ydb.yoj.repository.db.exception.SnapshotCreateException;
4242
import tech.ydb.yoj.repository.ydb.yql.YqlPrimitiveType;
4343
import tech.ydb.yoj.repository.ydb.yql.YqlType;
4444

@@ -336,9 +336,9 @@ private Table describeTableInternal(String path) {
336336

337337
Status status = result.getStatus();
338338
if (SCHEME_ERROR == status.getCode() && YdbIssue.DEFAULT_ERROR.isContainedIn(status.getIssues())) {
339-
throw new YdbSchemaPathNotFoundException(result.toString());
339+
throw new PathNotFoundException(result.toString());
340340
} else if (!result.isSuccess()) {
341-
throw new YdbRepositoryException("Can't describe table '" + path + "': " + result);
341+
throw new GenericSchemaException("Can't describe table '" + path + "': " + result);
342342
}
343343

344344
TableDescription table = result.getValue();
@@ -408,7 +408,7 @@ private void removeTablespace(String tablespace) {
408408
}
409409
}
410410

411-
public void snapshot(String snapshotPath) throws SnapshotCreateException {
411+
public void snapshot(String snapshotPath) {
412412
mkdirs(YdbPaths.canonicalRootDir(snapshotPath));
413413
getTableNames().forEach(tableName -> copyTable(tablespace + tableName, snapshotPath + tableName));
414414

@@ -476,7 +476,7 @@ public boolean hasPath(String path) {
476476
return false;
477477
}
478478

479-
throw new YdbRepositoryException("Can't describe table '" + path + "': " + result);
479+
throw new GenericSchemaException("Can't describe table '" + path + "': " + result);
480480
}
481481

482482
@Value

repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/client/YdbValidator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
import tech.ydb.yoj.InternalApi;
1010
import tech.ydb.yoj.repository.db.exception.DeadlineExceededException;
1111
import tech.ydb.yoj.repository.db.exception.EntityAlreadyExistsException;
12+
import tech.ydb.yoj.repository.db.exception.GenericSchemaException;
1213
import tech.ydb.yoj.repository.db.exception.OptimisticLockException;
1314
import tech.ydb.yoj.repository.db.exception.QueryCancelledException;
1415
import tech.ydb.yoj.repository.ydb.exception.BadSessionException;
1516
import tech.ydb.yoj.repository.ydb.exception.YdbClientInternalException;
1617
import tech.ydb.yoj.repository.ydb.exception.YdbComponentUnavailableException;
1718
import tech.ydb.yoj.repository.ydb.exception.YdbOverloadedException;
1819
import tech.ydb.yoj.repository.ydb.exception.YdbRepositoryException;
19-
import tech.ydb.yoj.repository.ydb.exception.YdbSchemaException;
2020
import tech.ydb.yoj.repository.ydb.exception.YdbUnauthenticatedException;
2121
import tech.ydb.yoj.repository.ydb.exception.YdbUnauthorizedException;
22+
import tech.ydb.yoj.util.lang.Strings;
2223

2324
import javax.annotation.Nullable;
2425
import java.util.function.Function;
@@ -120,7 +121,7 @@ public static void validate(String request, StatusCode statusCode, String respon
120121
}
121122

122123
// Database schema problem, e.g. trying to access a non-existent table, column etc. No retries
123-
case SCHEME_ERROR -> throw new YdbSchemaException("Schema error", request, response);
124+
case SCHEME_ERROR -> throw new GenericSchemaException(Strings.join("\n", "Schema error", request, response));
124125

125126
// Serious internal error. No retries
126127
case CLIENT_CALL_UNIMPLEMENTED,

repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/compatibility/YdbDataCompatibilityChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import tech.ydb.yoj.repository.db.StdTxManager;
1414
import tech.ydb.yoj.repository.db.Tx;
1515
import tech.ydb.yoj.repository.db.TxManager;
16+
import tech.ydb.yoj.repository.db.exception.SchemaException;
1617
import tech.ydb.yoj.repository.db.readtable.ReadTableParams;
1718
import tech.ydb.yoj.repository.ydb.YdbRepository;
18-
import tech.ydb.yoj.repository.ydb.exception.YdbSchemaException;
1919

2020
import java.time.Duration;
2121
import java.util.List;
@@ -63,7 +63,7 @@ public void run() {
6363
});
6464
} catch (Exception e) {
6565
String message = format("[%s] Got exception while checking entities of %s: ", sw, ec.getSimpleName());
66-
if (config.skipSchemaErrors && e instanceof YdbSchemaException) {
66+
if (config.skipSchemaErrors && e instanceof SchemaException) {
6767
log.warn(message);
6868
} else {
6969
log.error(message);

repository/src/main/java/tech/ydb/yoj/repository/db/exception/CreateTableException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package tech.ydb.yoj.repository.db.exception;
22

3-
public final class CreateTableException extends RepositoryException {
3+
public final class CreateTableException extends SchemaException {
44
public CreateTableException(String msg) {
55
super(msg);
66
}

repository/src/main/java/tech/ydb/yoj/repository/db/exception/DropTableException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package tech.ydb.yoj.repository.db.exception;
22

3-
public final class DropTableException extends RepositoryException {
3+
public final class DropTableException extends SchemaException {
44
public DropTableException(String msg) {
55
super(msg);
66
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package tech.ydb.yoj.repository.db.exception;
2+
3+
public final class GenericSchemaException extends SchemaException {
4+
public GenericSchemaException(String message) {
5+
super(message);
6+
}
7+
}

0 commit comments

Comments
 (0)