fix(api): missing error messages

This commit is contained in:
Gauthier Roebroeck 2021-09-17 17:06:44 +08:00
parent 49d519ddee
commit bc774d9615
2 changed files with 14 additions and 1 deletions

View file

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

View file

@ -44,6 +44,8 @@ server:
servlet.session.timeout: 7d
forward-headers-strategy: framework
shutdown: graceful
error:
include-message: always
management:
endpoints.web.exposure.include: "*"