|
20 | 20 |
|
21 | 21 | package com.arangodb.internal;
|
22 | 22 |
|
| 23 | +import com.arangodb.ArangoDBException; |
23 | 24 | import com.arangodb.ArangoGraphAsync;
|
24 | 25 | import com.arangodb.ArangoVertexCollectionAsync;
|
25 | 26 | import com.arangodb.entity.VertexEntity;
|
26 | 27 | import com.arangodb.entity.VertexUpdateEntity;
|
27 | 28 | import com.arangodb.model.*;
|
28 |
| -import org.slf4j.Logger; |
29 |
| -import org.slf4j.LoggerFactory; |
30 | 29 |
|
31 | 30 | import java.util.concurrent.CompletableFuture;
|
| 31 | +import java.util.concurrent.CompletionException; |
| 32 | + |
| 33 | +import static com.arangodb.internal.ArangoErrors.*; |
32 | 34 |
|
33 | 35 | /**
|
34 | 36 | * @author Mark Vollmary
|
35 | 37 | */
|
36 | 38 | public class ArangoVertexCollectionAsyncImpl extends InternalArangoVertexCollection implements ArangoVertexCollectionAsync {
|
37 | 39 |
|
38 |
| - private static final Logger LOGGER = LoggerFactory.getLogger(ArangoVertexCollectionAsyncImpl.class); |
39 |
| - |
40 | 40 | private final ArangoGraphAsync graph;
|
41 | 41 |
|
42 | 42 | protected ArangoVertexCollectionAsyncImpl(final ArangoGraphAsyncImpl graph, final String name) {
|
@@ -72,27 +72,24 @@ public CompletableFuture<VertexEntity> insertVertex(final Object value, final Ve
|
72 | 72 |
|
73 | 73 | @Override
|
74 | 74 | public <T> CompletableFuture<T> getVertex(final String key, final Class<T> type) {
|
75 |
| - return executorAsync().execute(() -> getVertexRequest(key, new GraphDocumentReadOptions()), |
76 |
| - getVertexResponseDeserializer(type)) |
77 |
| - .exceptionally(e -> { |
78 |
| - // FIXME |
79 |
| - if (LOGGER.isDebugEnabled()) { |
80 |
| - LOGGER.debug(e.getMessage(), e); |
81 |
| - } |
82 |
| - return null; |
83 |
| - }); |
84 |
| - |
| 75 | + return getVertex(key, type, null); |
85 | 76 | }
|
86 | 77 |
|
87 | 78 | @Override
|
88 | 79 | public <T> CompletableFuture<T> getVertex(final String key, final Class<T> type, final GraphDocumentReadOptions options) {
|
89 | 80 | return executorAsync().execute(() -> getVertexRequest(key, options), getVertexResponseDeserializer(type))
|
90 |
| - .exceptionally(e -> { |
91 |
| - // FIXME |
92 |
| - if (LOGGER.isDebugEnabled()) { |
93 |
| - LOGGER.debug(e.getMessage(), e); |
| 81 | + .exceptionally(err -> { |
| 82 | + Throwable e = err instanceof CompletionException ? err.getCause() : err; |
| 83 | + if (e instanceof ArangoDBException) { |
| 84 | + ArangoDBException aEx = (ArangoDBException) e; |
| 85 | + if (matches(aEx, 304) |
| 86 | + || matches(aEx, 404, ERROR_ARANGO_DOCUMENT_NOT_FOUND) |
| 87 | + || matches(aEx, 412, ERROR_ARANGO_CONFLICT) |
| 88 | + ) { |
| 89 | + return null; |
| 90 | + } |
94 | 91 | }
|
95 |
| - return null; |
| 92 | + throw ArangoDBException.of(e); |
96 | 93 | });
|
97 | 94 | }
|
98 | 95 |
|
|
0 commit comments