Skip to content

Commit 260db21

Browse files
authored
Update DynamoDBEnhanced publisher docs to make it clear how to handle errors. (#3449)
1 parent 999b6c0 commit 260db21

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/BatchGetResultPagePublisher.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
* batchGetResultPagePublisher.subscribe(page -> {
3737
* page.resultsForTable(firstItemTable).forEach(item -> System.out.println(item));
3838
* page.resultsForTable(secondItemTable).forEach(item -> System.out.println(item));
39+
* }).exceptionally(failure -> {
40+
* System.err.println("Failure occurred in subscription.");
41+
* failure.printStackTrace();
42+
* return null;
3943
* });
4044
* }
4145
* </pre>
@@ -44,8 +48,25 @@
4448
* 2) Subscribing to results across all pages.
4549
* <pre>
4650
* {@code
47-
* batchGetResultPagePublisher.resultsForTable(firstItemTable).subscribe(item -> System.out.println(item));
48-
* batchGetResultPagePublisher.resultsForTable(secondItemTable).subscribe(item -> System.out.println(item));
51+
* CompletableFuture<Void> resultFuture1 =
52+
* batchGetResultPagePublisher.resultsForTable(firstItemTable)
53+
* .subscribe(item -> System.out.println(item));
54+
*
55+
* CompletableFuture<Void> resultFuture2 =
56+
* batchGetResultPagePublisher.resultsForTable(secondItemTable)
57+
* .subscribe(item -> System.out.println(item));
58+
*
59+
* resultFuture1.exceptionally(failure -> {
60+
* System.err.println("Failure occurred in results for table " + firstItemTable);
61+
* failure.printStackTrace();
62+
* return null;
63+
* });
64+
*
65+
* resultFuture2.exceptionally(failure -> {
66+
* System.err.println("Failure occurred in results for table " + secondItemTable);
67+
* failure.printStackTrace();
68+
* return null;
69+
* });
4970
* }
5071
* </pre>
5172
*/

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/PagePublisher.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
* {@code
3232
*
3333
* PagePublisher<MyItem> publisher = mappedTable.scan();
34-
* publisher.subscribe(page -> page.items().forEach(item -> System.out.println(item)));
34+
* publisher.subscribe(page -> page.items().forEach(item -> System.out.println(item)))
35+
* .exceptionally(failure -> {
36+
* failure.printStackTrace();
37+
* return null;
38+
* });
3539
* }
3640
* </pre>
3741
*
@@ -41,7 +45,12 @@
4145
* {@code
4246
*
4347
* PagePublisher<MyItem> publisher = mappedTable.scan();
44-
* publisher.items().subscribe(item -> System.out.println(item));
48+
* publisher.items()
49+
* .subscribe(item -> System.out.println(item))
50+
* .exceptionally(failure -> {
51+
* failure.printStackTrace();
52+
* return null;
53+
* });
4554
* }
4655
* </pre>
4756
*

0 commit comments

Comments
 (0)