Skip to content
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

Catching empty response on PlaybackState #192

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

hayribakici
Copy link
Collaborator

@hayribakici hayribakici commented Jan 2, 2024

Fixes #191. Returns an empty PlaybackState object if the response is empty.
@rinukkusu should rather maybe an error be returned instead? E.g.

Future<PlaybackState> playbackState([Market? market]) async {
    var jsonString = await _api._get(...);
    if (jsonString.isEmpty) {
      return Future.error(SpotifyException('No playback context found'));
    }
...
}

@hayribakici hayribakici changed the title fixes #191 Catching empty response on PlaybackState Jan 2, 2024
@rinukkusu
Copy link
Owner

rinukkusu commented Feb 7, 2024

Wondering how you would check for a valid PlaybackState. Check if playbackState.item is null? Maybe it's more descriptive to make the return type nullable and just return null as a whole?

I don't think this should be an error, because it's really just "empty" data.

Either way a conflict has to be resolved before I can merge this fix 😆

@rinukkusu rinukkusu merged commit f2f0d25 into rinukkusu:master Feb 12, 2024
2 checks passed
@hayribakici hayribakici deleted the #191_404 branch February 12, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

404 Device not found (and unhandled exception)
2 participants