From ebfc5e13764ee49cfab897f872b3a26e22654b14 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Mon, 22 Nov 2021 16:09:23 +0800 Subject: [PATCH] fix: use more specific error code when file is not found during analysis --- .../kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt index 06a92552..a0aae5cb 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt @@ -13,6 +13,7 @@ import org.gotson.komga.infrastructure.mediacontainer.ContentDetector import org.gotson.komga.infrastructure.mediacontainer.MediaContainerExtractor import org.springframework.stereotype.Service import java.nio.file.AccessDeniedException +import java.nio.file.NoSuchFileException private val logger = KotlinLogging.logger {} @@ -75,6 +76,9 @@ class BookAnalyzer( } catch (ade: AccessDeniedException) { logger.error(ade) { "Error while analyzing book: $book" } return Media(status = Media.Status.ERROR, comment = "ERR_1000", bookId = book.id) + } catch (ex: NoSuchFileException) { + logger.error(ex) { "Error while analyzing book: $book" } + return Media(status = Media.Status.ERROR, comment = "ERR_1018", bookId = book.id) } catch (ex: Exception) { logger.error(ex) { "Error while analyzing book: $book" } return Media(status = Media.Status.ERROR, comment = "ERR_1005", bookId = book.id)