Skip to content

Commit 178e793

Browse files
committed
🐛 Properly handle error
1 parent 2b36633 commit 178e793

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/rxdart_flatmap_max_concurrent.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class SimpleClient extends http.BaseClient {
3131
return _client
3232
.send(entry.request)
3333
.asStream()
34+
.doOnError(entry.completer.completeError)
3435
.doOnData(entry.completer.complete)
36+
.onErrorResumeNext(Stream.empty())
3537
.doOnCancel(() => print('SimpleClient: <-- ${entry.request.url}'));
3638
}
3739

@@ -65,7 +67,8 @@ void main() async {
6567
for (var i = 1; i <= 5; i++)
6668
simpleClient
6769
.get(Uri.parse('https://jsonplaceholder.typicode.com/users/$i'))
68-
.then((res) => print('Response: id=$i -> ${res.statusCode}')),
70+
.then((res) => print('Response: id=$i -> ${res.statusCode}'))
71+
.onError((e, s) => print('Response: id=$i -> $e, $s')),
6972
];
7073

7174
await Future.wait(futures);

0 commit comments

Comments
 (0)