refactor: improve error handling in manga search methods with logging
This commit is contained in:
parent
bc8fe69e20
commit
0c056541bd
@ -48,7 +48,9 @@ public class MangaResolutionService {
|
||||
}
|
||||
|
||||
private Optional<ProviderResult> searchMangaOnAniList(String title) {
|
||||
try {
|
||||
var searchResults = aniListService.searchMangaByTitle(title);
|
||||
|
||||
if (searchResults.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -73,9 +75,14 @@ public class MangaResolutionService {
|
||||
: matchedManga.title().english();
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, matchedManga.id()));
|
||||
} catch (Exception e) {
|
||||
log.error("Error searching for manga with title {} on AniList: {}", title, e.getMessage());
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<ProviderResult> searchMangaOnMyAnimeList(String title) {
|
||||
try {
|
||||
var searchResults = myAnimeListService.searchMangaByTitle(title);
|
||||
if (searchResults.isEmpty()) {
|
||||
return Optional.empty();
|
||||
@ -96,6 +103,11 @@ public class MangaResolutionService {
|
||||
var malId = searchResults.get(bestTitle);
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, malId));
|
||||
} catch (Exception e) {
|
||||
log.error(
|
||||
"Error searching for manga with title {} on MyAnimeList: {}", title, e.getMessage());
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public Manga findOrCreateManga(Long aniListId, Long malId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user