fix: use more specific error code when file is not found during analysis

This commit is contained in:
Gauthier Roebroeck 2021-11-22 16:09:23 +08:00
parent 32f4d7f651
commit ebfc5e1376

View file

@ -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)