mirror of https://github.com/usbharu/Hideout.git
feat: アカウントが見つからなかった場合のエラーハンドリングを追加
This commit is contained in:
parent
208d1c519a
commit
5fad278b0b
|
@ -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<NotFoundResponse> {
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -152,7 +152,6 @@ class AccountApiServiceImpl(
|
|||
return@transaction accountService.findById(id)
|
||||
}
|
||||
} catch (e: UserNotFoundException) {
|
||||
logger.debug("Account Not found $id")
|
||||
throw AccountNotFoundException.ofId(id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue