fix: handle missing Komga configuration gracefully by returning an empty array instead of an error in API routes

This commit is contained in:
Julien Froidefond
2025-10-17 08:37:08 +02:00
parent b8af5e2468
commit bf94c29bc6
6 changed files with 418 additions and 784 deletions

View File

@@ -29,6 +29,12 @@ export async function GET() {
return NextResponse.json(validFavoriteIds);
} catch (error) {
if (error instanceof AppError) {
// Si la config Komga n'existe pas, retourner un tableau vide au lieu d'une erreur
if (error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
return NextResponse.json([]);
}
}
console.error("Erreur lors de la récupération des favoris:", error);
if (error instanceof AppError) {
return NextResponse.json(

View File

@@ -11,6 +11,12 @@ export async function GET() {
const libraries: KomgaLibrary[] = await LibraryService.getLibraries();
return NextResponse.json(libraries);
} catch (error) {
if (error instanceof AppError) {
// Si la config Komga n'existe pas, retourner un tableau vide au lieu d'une erreur
if (error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
return NextResponse.json([]);
}
}
console.error("API Libraries - Erreur:", error);
if (error instanceof AppError) {
return NextResponse.json(