feat: キャッチする例外を修正

This commit is contained in:
usbharu 2023-10-11 15:44:43 +09:00
parent f33e04faa5
commit 7fac732150
3 changed files with 7 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import dev.usbharu.hideout.exception.UserNotFoundException
import dev.usbharu.hideout.query.PostQueryService import dev.usbharu.hideout.query.PostQueryService
import dev.usbharu.hideout.repository.PostRepository import dev.usbharu.hideout.repository.PostRepository
import dev.usbharu.hideout.repository.UserRepository import dev.usbharu.hideout.repository.UserRepository
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.Instant import java.time.Instant
import java.util.* import java.util.*
@ -34,7 +35,7 @@ class PostServiceImpl(
private suspend fun internalCreate(post: Post, isLocal: Boolean): Post { private suspend fun internalCreate(post: Post, isLocal: Boolean): Post {
val save = try { val save = try {
postRepository.save(post) postRepository.save(post)
} catch (e: Exception) { } catch (e: ExposedSQLException) {
postQueryService.findByApId(post.apId) postQueryService.findByApId(post.apId)
} }
timelineService.publishTimeline(save, isLocal) timelineService.publishTimeline(save, isLocal)

View File

@ -4,6 +4,7 @@ import dev.usbharu.hideout.domain.model.hideout.entity.Reaction
import dev.usbharu.hideout.query.ReactionQueryService import dev.usbharu.hideout.query.ReactionQueryService
import dev.usbharu.hideout.repository.ReactionRepository import dev.usbharu.hideout.repository.ReactionRepository
import dev.usbharu.hideout.service.ap.APReactionService import dev.usbharu.hideout.service.ap.APReactionService
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@ -20,8 +21,9 @@ class ReactionServiceImpl(
reactionRepository.save( reactionRepository.save(
Reaction(reactionRepository.generateId(), 0, postId, userId) Reaction(reactionRepository.generateId(), 0, postId, userId)
) )
} catch (_: Exception) { } catch (e: ExposedSQLException) {
LOGGER.warn("FAILED Failure to persist reaction information.") LOGGER.warn("FAILED Failure to persist reaction information.")
LOGGER.debug("FAILED", e)
} }
} }
} }

View File

@ -10,6 +10,7 @@ import dev.usbharu.hideout.query.FollowerQueryService
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.repository.UserRepository import dev.usbharu.hideout.repository.UserRepository
import dev.usbharu.hideout.service.ap.APSendFollowService import dev.usbharu.hideout.service.ap.APSendFollowService
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.Instant import java.time.Instant
@ -66,7 +67,7 @@ class UserServiceImpl(
) )
return try { return try {
userRepository.save(userEntity) userRepository.save(userEntity)
} catch (e: Exception) { } catch (e: ExposedSQLException) {
userQueryService.findByUrl(user.url) userQueryService.findByUrl(user.url)
} }
} }