Skip to content

Commit 6d98685

Browse files
author
a-brandt
committed
added error handling
1 parent 3bd8cb6 commit 6d98685

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import com.arangodb.http.BatchHttpManager;
7474
import com.arangodb.http.BatchPart;
7575
import com.arangodb.http.HttpManager;
76+
import com.arangodb.http.HttpResponseEntity;
7677
import com.arangodb.http.InvocationHandlerImpl;
7778
import com.arangodb.impl.ImplFactory;
7879
import com.arangodb.impl.InternalBatchDriverImpl;
@@ -408,8 +409,21 @@ public <T> T getBatchResponseByRequestId(final String requestId) throws ArangoEx
408409
this.httpManager.setPreDefinedResponse(null);
409410
return result;
410411
} catch (final InvocationTargetException e) {
411-
final T result = (T) createEntity(batchResponseEntity.getHttpResponseEntity(), DefaultEntity.class);
412412
this.httpManager.setPreDefinedResponse(null);
413+
414+
HttpResponseEntity httpResponse = batchResponseEntity.getHttpResponseEntity();
415+
if (httpResponse.getStatusCode() >= 300) {
416+
DefaultEntity de = new DefaultEntity();
417+
de.setCode(httpResponse.getStatusCode());
418+
de.setError(true);
419+
if (httpResponse.getText() != null) {
420+
de.setErrorMessage(httpResponse.getText().trim());
421+
}
422+
de.setErrorNumber(httpResponse.getStatusCode());
423+
throw new ArangoException(de);
424+
}
425+
426+
final T result = (T) createEntity(batchResponseEntity.getHttpResponseEntity(), DefaultEntity.class);
413427
return result;
414428
} catch (final Exception e) {
415429
this.httpManager.setPreDefinedResponse(null);

0 commit comments

Comments
 (0)