mirror of
https://github.com/usbharu/Hideout.git
synced 2026-08-04 20:24:56 +00:00
feat: アカウントが見つからなかった場合のエラーハンドリングを追加
This commit is contained in:
+7
@@ -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.NotFoundResponse
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.UnprocessableEntityResponse
|
import dev.usbharu.hideout.domain.mastodon.model.generated.UnprocessableEntityResponse
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.UnprocessableEntityResponseDetails
|
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.domain.exception.StatusNotFoundException
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.account.MastodonAccountApiController
|
import dev.usbharu.hideout.mastodon.interfaces.api.account.MastodonAccountApiController
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.apps.MastodonAppsApiController
|
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)
|
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 {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(MastodonApiControllerAdvice::class.java)
|
private val logger = LoggerFactory.getLogger(MastodonApiControllerAdvice::class.java)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ class AccountApiServiceImpl(
|
|||||||
return@transaction accountService.findById(id)
|
return@transaction accountService.findById(id)
|
||||||
}
|
}
|
||||||
} catch (e: UserNotFoundException) {
|
} catch (e: UserNotFoundException) {
|
||||||
logger.debug("Account Not found $id")
|
|
||||||
throw AccountNotFoundException.ofId(id)
|
throw AccountNotFoundException.ofId(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user