Skip to content

Commit

Permalink
chore: Improve error handling in SpinifyCommandMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed May 12, 2024
1 parent 54d3990 commit e054dac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/src/spinify_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ base mixin SpinifyCommandMixin on SpinifyBase {

@override
Future<void> _onReply(SpinifyReply reply) async {
if (reply.id case int id when id > 0) _replies.remove(id)?.complete(reply);
assert(reply.id > -1, 'Reply ID should be greater or equal to 0');
if (reply.id case int id when id > 0) {
final completer = _replies.remove(id);
assert(completer != null, 'Reply completer not found');
completer?.complete(reply);
}
await super._onReply(reply);
}

Expand Down

0 comments on commit e054dac

Please sign in to comment.