From 1481841009150d84abac1a28521f7f823af745c8 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 16 Jul 2023 16:19:25 +0200 Subject: [PATCH] fix: Guard against Jikan errors when refreshing the calendar --- lib/src/ui/bloc/calendar_bloc.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/bloc/calendar_bloc.dart b/lib/src/ui/bloc/calendar_bloc.dart index fd27c7e..332f7af 100644 --- a/lib/src/ui/bloc/calendar_bloc.dart +++ b/lib/src/ui/bloc/calendar_bloc.dart @@ -40,7 +40,14 @@ class CalendarBloc extends Bloc { for (final anime in animes) { emit(state.copyWith(refreshingCount: state.refreshingCount + 1)); - final apiData = await Jikan().getAnime(int.parse(anime.id)); + Anime apiData; + try { + apiData = await Jikan().getAnime(int.parse(anime.id)); + } catch (_) { + print('API request for anime ${anime.id} failed'); + continue; + } + if (!apiData.airing) { al.add( AnimeUpdatedEvent(