Improve failure message by using itemType.name

- Replace raw itemType (e.g. "ItemType.manga") with itemType.name (e.g. "manga") for better legibility.
This commit is contained in:
NBA2K1 2026-02-22 14:45:01 +01:00
parent bf90db44c4
commit e1fa1f75bc

View file

@ -15,10 +15,10 @@ Future<void> updateLibrary({
required List<Manga> mangaList, required List<Manga> mangaList,
required ItemType itemType, required ItemType itemType,
}) async { }) async {
AppLogger.log("Starting ${itemType.name} library update..."); final itemtype = itemType.name[0].toUpperCase() + itemType.name.substring(1);
AppLogger.log("Starting $itemtype library update...");
if (mangaList.isEmpty) { if (mangaList.isEmpty) {
final cap = itemType.name[0].toUpperCase() + itemType.name.substring(1); AppLogger.log("$itemtype library is empty. Nothing to update.");
AppLogger.log("$cap library is empty. Nothing to update.");
return; return;
} }
bool isDark = ref.read(themeModeStateProvider); bool isDark = ref.read(themeModeStateProvider);
@ -42,13 +42,10 @@ Future<void> updateLibrary({
).future, ).future,
); );
} catch (e) { } catch (e) {
AppLogger.log( AppLogger.log("Failed to update $itemtype:", logLevel: LogLevel.error);
"Failed to update ${itemType.name}:",
logLevel: LogLevel.error,
);
AppLogger.log(e.toString(), logLevel: LogLevel.error); AppLogger.log(e.toString(), logLevel: LogLevel.error);
failed++; failed++;
failedMangas.add(manga.name ?? "Unknown ${itemType.name}"); failedMangas.add(manga.name ?? "Unknown $itemtype");
} }
if (context.mounted) { if (context.mounted) {
botToast( botToast(
@ -67,7 +64,7 @@ Future<void> updateLibrary({
BotToast.cleanAll(); BotToast.cleanAll();
if (context.mounted && failedMangas.isNotEmpty) { if (context.mounted && failedMangas.isNotEmpty) {
final failedListText = failedMangas.map((m) => "$m").join('\n'); final failedListText = failedMangas.map((m) => "$m").join('\n');
final plural = failed == 1 ? itemType : "${itemType}s"; final plural = failed == 1 ? itemtype : "${itemtype}s";
botToast( botToast(
"Failed to update $failed $plural:\n$failedListText", "Failed to update $failed $plural:\n$failedListText",
fontSize: 13, fontSize: 13,