Skip to content

Commit d923711

Browse files
committed
Improve getSchemaExceptions() to return TypeDBException that contains code and message
1 parent 906e0b8 commit d923711

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

api/concept/ConceptManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.vaticle.typedb.client.api.concept.type.EntityType;
2727
import com.vaticle.typedb.client.api.concept.type.RelationType;
2828
import com.vaticle.typedb.client.api.concept.type.ThingType;
29+
import com.vaticle.typedb.client.common.exception.TypeDBException;
2930

3031
import java.util.List;
3132
import javax.annotation.CheckReturnValue;
@@ -72,5 +73,5 @@ public interface ConceptManager {
7273
AttributeType putAttributeType(String label, AttributeType.ValueType valueType);
7374

7475
@CheckReturnValue
75-
List<String> getSchemaExceptions();
76+
List<TypeDBException> getSchemaExceptions();
7677
}

common/exception/TypeDBException.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2022 Vaticle
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
package com.vaticle.typedb.client.common.exception;
23+
24+
public class TypeDBException extends RuntimeException {
25+
26+
public String code;
27+
public String message;
28+
29+
public TypeDBException(String code, String message) {
30+
super(message);
31+
this.code = code;
32+
this.message = message;
33+
}
34+
}

concept/ConceptManagerImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.vaticle.typedb.client.api.concept.type.EntityType;
2929
import com.vaticle.typedb.client.api.concept.type.RelationType;
3030
import com.vaticle.typedb.client.api.concept.type.ThingType;
31+
import com.vaticle.typedb.client.common.exception.TypeDBException;
3132
import com.vaticle.typedb.client.concept.thing.ThingImpl;
3233
import com.vaticle.typedb.client.concept.type.AttributeTypeImpl;
3334
import com.vaticle.typedb.client.concept.type.EntityTypeImpl;
@@ -46,6 +47,7 @@
4647
import static com.vaticle.typedb.client.common.rpc.RequestBuilder.ConceptManager.putAttributeTypeReq;
4748
import static com.vaticle.typedb.client.common.rpc.RequestBuilder.ConceptManager.putEntityTypeReq;
4849
import static com.vaticle.typedb.client.common.rpc.RequestBuilder.ConceptManager.putRelationTypeReq;
50+
import static java.util.stream.Collectors.toList;
4951

5052
public final class ConceptManagerImpl implements ConceptManager {
5153

@@ -142,8 +144,9 @@ public Thing getThing(String iid) {
142144
}
143145

144146
@Override
145-
public List<String> getSchemaExceptions() {
146-
return execute(getSchemaExceptionsReq()).getGetSchemaExceptionsRes().getExceptionsList();
147+
public List<TypeDBException> getSchemaExceptions() {
148+
return execute(getSchemaExceptionsReq()).getGetSchemaExceptionsRes().getExceptionsList().stream()
149+
.map(e -> new TypeDBException(e.getCode(), e.getMessage())).collect(toList());
147150
}
148151

149152
private ConceptProto.ConceptManager.Res execute(TransactionProto.Transaction.Req.Builder req) {

dependencies/vaticle/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def vaticle_typedb_protocol():
4646
git_repository(
4747
name = "vaticle_typedb_protocol",
4848
remote = "https://github.com/vaticle/typedb-protocol",
49-
commit = "26782a597b83c97f55b14428b13207fc5d9b9f18", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_protocol
49+
commit = "a86f8ffeff1699881c5418c8976315536357a1c8", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_protocol
5050
)
5151

5252
def vaticle_typedb_behaviour():

0 commit comments

Comments
 (0)