fix: Guard against Jikan errors when refreshing the calendar

This commit is contained in:
PapaTutuWawa 2023-07-16 16:19:25 +02:00
parent 918e42b424
commit 1481841009

View File

@ -40,7 +40,14 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
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(