From 268f8427d609adfe42ff82084c2b4a18d9a38ec5 Mon Sep 17 00:00:00 2001 From: tommyxchow Date: Sat, 15 Jan 2022 13:37:43 -0500 Subject: [PATCH] Add try-catch to video store --- lib/api/twitch_api.dart | 2 +- lib/screens/channel/stores/video_store.dart | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/api/twitch_api.dart b/lib/api/twitch_api.dart index c6f7d715..1b10ebeb 100644 --- a/lib/api/twitch_api.dart +++ b/lib/api/twitch_api.dart @@ -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.'); diff --git a/lib/screens/channel/stores/video_store.dart b/lib/screens/channel/stores/video_store.dart index 3dfc7f16..84dbfc25 100644 --- a/lib/screens/channel/stores/video_store.dart +++ b/lib/screens/channel/stores/video_store.dart @@ -72,9 +72,11 @@ abstract class _VideoStoreBase with Store { @action Future 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()); } }