diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/springweb/MastodonApiControllerAdvice.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/springweb/MastodonApiControllerAdvice.kt index 003b071f..b154f52b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/springweb/MastodonApiControllerAdvice.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/springweb/MastodonApiControllerAdvice.kt @@ -19,6 +19,7 @@ package dev.usbharu.hideout.mastodon.infrastructure.springweb import dev.usbharu.hideout.domain.mastodon.model.generated.NotFoundResponse import dev.usbharu.hideout.domain.mastodon.model.generated.UnprocessableEntityResponse import dev.usbharu.hideout.domain.mastodon.model.generated.UnprocessableEntityResponseDetails +import dev.usbharu.hideout.mastodon.domain.exception.AccountNotFoundException import dev.usbharu.hideout.mastodon.domain.exception.StatusNotFoundException import dev.usbharu.hideout.mastodon.interfaces.api.account.MastodonAccountApiController import dev.usbharu.hideout.mastodon.interfaces.api.apps.MastodonAppsApiController @@ -98,6 +99,12 @@ class MastodonApiControllerAdvice { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getTypedResponse().response) } + @ExceptionHandler(AccountNotFoundException::class) + fun handleException(ex: AccountNotFoundException): ResponseEntity { + logger.warn("Account not found.", ex) + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getTypedResponse().response) + } + companion object { private val logger = LoggerFactory.getLogger(MastodonApiControllerAdvice::class.java) } diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt index 7c091999..c9f15567 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt @@ -152,7 +152,6 @@ class AccountApiServiceImpl( return@transaction accountService.findById(id) } } catch (e: UserNotFoundException) { - logger.debug("Account Not found $id") throw AccountNotFoundException.ofId(id) } }