fix: リプライ先取得失敗時のエラーハンドリングを修正

This commit is contained in:
usbharu 2023-11-13 15:03:38 +09:00
parent 41da5f1acd
commit 31d61435dd
1 changed files with 11 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import dev.usbharu.hideout.util.singleOr
import org.jetbrains.exposed.sql.Query
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Repository
import java.time.Instant
@ -47,7 +48,12 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
private suspend fun ResultRow.toNote(mediaList: List<dev.usbharu.hideout.core.domain.model.media.Media>): Note {
val replyId = this[Posts.replyId]
val replyTo = if (replyId != null) {
postRepository.findById(replyId).url
try {
postRepository.findById(replyId).url
} catch (e: FailedToGetResourcesException) {
logger.warn("Failed to get replyId: $replyId", e)
null
}
} else {
null
}
@ -86,4 +92,8 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v
Visibility.DIRECT -> TODO()
}
}
companion object {
private val logger = LoggerFactory.getLogger(NoteQueryServiceImpl::class.java)
}
}