Java Code Examples for com.arangodb.ArangoDBException#getResponseCode()
The following examples show how to use
com.arangodb.ArangoDBException#getResponseCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArangoCollectionAsyncImpl.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
private <T> Function<Throwable, T> handleGetDocumentExceptions(Boolean isCatchException) { return throwable -> { if (throwable instanceof CompletionException) { if (throwable.getCause() instanceof ArangoDBException) { ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause(); // handle Response: 404, Error: 1655 - transaction not found if (arangoDBException.getErrorNum() != null && arangoDBException.getErrorNum() == 1655) { throw (CompletionException) throwable; } if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304 || arangoDBException.getResponseCode() == 412)) && isCatchException) { return null; } } throw (CompletionException) throwable; } throw new CompletionException(throwable); }; }
Example 2
Source File: ArangoCollectionImpl.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Override public <T> T getDocument(final String key, final Class<T> type, final DocumentReadOptions options) throws ArangoDBException { DocumentUtil.validateDocumentKey(key); try { return executor.execute(getDocumentRequest(key, options), type); } catch (final ArangoDBException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(e.getMessage(), e); } // handle Response: 404, Error: 1655 - transaction not found if (e.getErrorNum() != null && e.getErrorNum() == 1655) { throw e; } if ((e.getResponseCode() != null && (e.getResponseCode() == 404 || e.getResponseCode() == 304 || e.getResponseCode() == 412)) && (options == null || options.isCatchException())) { return null; } throw e; } }
Example 3
Source File: ArangoCollectionImpl.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Override public Boolean documentExists(final String key, final DocumentExistsOptions options) throws ArangoDBException { try { executor.execute(documentExistsRequest(key, options), VPackSlice.class); return true; } catch (final ArangoDBException e) { // handle Response: 404, Error: 1655 - transaction not found if (e.getErrorNum() != null && e.getErrorNum() == 1655) { throw e; } if ((e.getResponseCode() != null && (e.getResponseCode() == 404 || e.getResponseCode() == 304 || e.getResponseCode() == 412)) && (options == null || options.isCatchException())) { return false; } throw e; } }
Example 4
Source File: ExceptionUtil.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
static <T> Function<Throwable, T> catchGetDocumentExceptions(Boolean isCatchException) { return throwable -> { if (throwable instanceof CompletionException) { if (throwable.getCause() instanceof ArangoDBException) { ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause(); // handle Response: 404, Error: 1655 - transaction not found if (arangoDBException.getErrorNum() != null && arangoDBException.getErrorNum() == 1655) { throw (CompletionException) throwable; } if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304 || arangoDBException.getResponseCode() == 412)) && isCatchException) { return null; } } throw (CompletionException) throwable; } throw new CompletionException(throwable); }; }
Example 5
Source File: ExtendedHostResolver.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
private Collection<String> resolveFromServer() throws ArangoDBException { Collection<String> response; try { response = executor.execute( new Request(ArangoRequestParam.SYSTEM, RequestType.GET, "/_api/cluster/endpoints"), response1 -> { final VPackSlice field = response1.getBody().get("endpoints"); Collection<String> endpoints; if (field.isNone()) { endpoints = Collections.emptyList(); } else { final Collection<Map<String, String>> tmp = arangoSerialization.deserialize(field, Collection.class); endpoints = new ArrayList<>(); for (final Map<String, String> map : tmp) { endpoints.addAll(map.values()); } } return endpoints; }, null); } catch (final ArangoDBException e) { final Integer responseCode = e.getResponseCode(); // responseCode == 403: single server < 3.7 // responseCode == 501: single server >= 3.7 if (responseCode != null && (responseCode == 403 || responseCode == 501)) { response = Collections.emptyList(); } else { throw e; } } return response; }