From bc774d961548c6cec3c89d6ba51a30d217bc8a6e Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 17 Sep 2021 17:06:44 +0800 Subject: [PATCH] fix(api): missing error messages --- .../komga/interfaces/rest/LibraryController.kt | 13 ++++++++++++- komga/src/main/resources/application.yml | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt index 2e1ba2000..e7b144a63 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt @@ -132,7 +132,18 @@ class LibraryController( emptyTrashAfterScan = library.emptyTrashAfterScan, seriesCover = library.seriesCover.toDomain(), ) - libraryLifecycle.updateLibrary(toUpdate) + try { + libraryLifecycle.updateLibrary(toUpdate) + } catch (e: Exception) { + when (e) { + is FileNotFoundException, + is DirectoryNotFoundException, + is DuplicateNameException, + is PathContainedInPath -> + throw ResponseStatusException(HttpStatus.BAD_REQUEST, e.message) + else -> throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR) + } + } } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) } diff --git a/komga/src/main/resources/application.yml b/komga/src/main/resources/application.yml index d58118690..94d3de0bd 100644 --- a/komga/src/main/resources/application.yml +++ b/komga/src/main/resources/application.yml @@ -44,6 +44,8 @@ server: servlet.session.timeout: 7d forward-headers-strategy: framework shutdown: graceful + error: + include-message: always management: endpoints.web.exposure.include: "*"