Add try-catch to video store

This commit is contained in:
tommyxchow 2022-01-15 13:37:43 -05:00
parent 98fabafbdb
commit 268f8427d6
2 changed files with 5 additions and 3 deletions

View file

@ -227,7 +227,7 @@ class TwitchApi {
if (data.isNotEmpty) {
return StreamTwitch.fromJson(data.first);
} else {
throw Exception('User is offline or does not exist.');
throw Exception('$userLogin is offline');
}
} else {
throw Exception('Failed to get stream info.');

View file

@ -72,9 +72,11 @@ abstract class _VideoStoreBase with Store {
@action
Future<void> updateStreamInfo() async {
final updatedStreamInfo = await twitchApi.getStream(userLogin: userLogin, headers: authStore.headersTwitch);
if (updatedStreamInfo != null) {
try {
final updatedStreamInfo = await twitchApi.getStream(userLogin: userLogin, headers: authStore.headersTwitch);
_streamInfo = updatedStreamInfo;
} catch (e) {
debugPrint(e.toString());
}
}