Skip to content

Fix throw in LiveList #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/dart/lib/src/utils/parse_live_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,17 @@ class ParseLiveList<T extends ParseObject> {
keyVarObjectId, _list[index].object.get<String>(keyVarObjectId))
..setLimit(1);
final ParseResponse response = await queryBuilder.query<T>();
if (_list.isEmpty) {
yield* _createStreamError<T>(
ParseError(message: 'ParseLiveList: _list is empty'));
return;
}
if (response.success) {
_list[index].object = response.results?.first;
} else {
_list[index].object = null;
throw response.error;
yield* _createStreamError<T>(response.error);
return;
}
}
// just for testing
Expand Down Expand Up @@ -732,7 +738,6 @@ class ParseLiveListDeleteEvent<T extends ParseObject>
typedef StreamGetter<T extends ParseObject> = Stream<T> Function();
typedef DataGetter<T extends ParseObject> = T Function();


class ParseLiveListElementSnapshot<T extends ParseObject> {
ParseLiveListElementSnapshot({this.loadedData, this.error});

Expand All @@ -743,5 +748,3 @@ class ParseLiveListElementSnapshot<T extends ParseObject> {

bool get failed => error != null;
}


4 changes: 4 additions & 0 deletions packages/dart/lib/src/utils/parse_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ Future<ParseResponse> batchRequest(
return handleException(e, ParseApiRQ.batch, debug, 'parse_utils');
}
}

Stream<T> _createStreamError<T>(Object error) async* {
throw error;
}