refactor: enhance error handling in fetchExternalMangaData method

This commit is contained in:
Rodrigo Verdiani 2026-03-29 13:41:40 -03:00
parent 533e7ce21a
commit 7df2ea1b7a

View File

@ -71,12 +71,28 @@ public class MangaUpdateService {
}
private MangaDataDTO fetchExternalMangaData(Manga manga) {
Exception fetchException = null;
if (nonNull(manga.getAniListId())) {
return aniListService.getMangaDataById(manga.getAniListId());
try {
return aniListService.getMangaDataById(manga.getAniListId());
} catch (Exception e) {
log.warn("Failed to fetch manga data from AniList for Manga ID {}", manga.getId(), e);
fetchException = e;
}
}
if (nonNull(manga.getMalId())) {
return myAnimeListService.getMangaDataById(manga.getMalId());
try {
return myAnimeListService.getMangaDataById(manga.getMalId());
} catch (Exception e) {
log.warn("Failed to fetch manga data from MyAnimeList for Manga ID {}", manga.getId(), e);
fetchException = e;
}
}
if (nonNull(fetchException)) {
throw (RuntimeException) fetchException;
}
throw new IllegalStateException(