Skip to content

Commit 8927058

Browse files
authored
fix(datastore): List errors that are returned from AppSync (#2801)
1 parent 2438647 commit 8927058

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

aws-datastore/src/main/java/com/amplifyframework/datastore/syncengine/SyncProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.util.List;
5454
import java.util.Objects;
5555
import java.util.concurrent.atomic.AtomicReference;
56+
import java.util.stream.Collectors;
5657

5758
import io.reactivex.rxjava3.core.Completable;
5859
import io.reactivex.rxjava3.core.Flowable;
@@ -320,8 +321,13 @@ private <T extends Model> Single<GraphQLResponse<PaginatedResult<ModelWithMetada
320321
return Single.create(emitter -> {
321322
Cancelable cancelable = appSync.sync(request, result -> {
322323
if (!result.hasData()) {
324+
List<String> errorStrings = result.getErrors().stream()
325+
.map(GraphQLResponse.Error::toString)
326+
.collect(Collectors.toList());
327+
String errors = String.join(",\n", errorStrings);
328+
323329
emitter.onError(new DataStoreException.IrRecoverableException(
324-
"Empty response from AppSync.", "Report to AWS team."
330+
"Received errors from AppSync: " + errors, "Report to AWS team."
325331
));
326332
} else {
327333
if (result.hasErrors()) {

0 commit comments

Comments
 (0)