From 7fac732150a0977fd92f7c888e7b02cd9074f406 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:44:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=82=AD=E3=83=A3=E3=83=83=E3=83=81?= =?UTF-8?q?=E3=81=99=E3=82=8B=E4=BE=8B=E5=A4=96=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/usbharu/hideout/service/post/PostServiceImpl.kt | 3 ++- .../usbharu/hideout/service/reaction/ReactionServiceImpl.kt | 4 +++- .../dev/usbharu/hideout/service/user/UserServiceImpl.kt | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/post/PostServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/post/PostServiceImpl.kt index 5b376c68..f4d36084 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/post/PostServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/post/PostServiceImpl.kt @@ -6,6 +6,7 @@ import dev.usbharu.hideout.exception.UserNotFoundException import dev.usbharu.hideout.query.PostQueryService import dev.usbharu.hideout.repository.PostRepository import dev.usbharu.hideout.repository.UserRepository +import org.jetbrains.exposed.exceptions.ExposedSQLException import org.springframework.stereotype.Service import java.time.Instant import java.util.* @@ -34,7 +35,7 @@ class PostServiceImpl( private suspend fun internalCreate(post: Post, isLocal: Boolean): Post { val save = try { postRepository.save(post) - } catch (e: Exception) { + } catch (e: ExposedSQLException) { postQueryService.findByApId(post.apId) } timelineService.publishTimeline(save, isLocal) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt index 07519bcc..6e56143f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/reaction/ReactionServiceImpl.kt @@ -4,6 +4,7 @@ import dev.usbharu.hideout.domain.model.hideout.entity.Reaction import dev.usbharu.hideout.query.ReactionQueryService import dev.usbharu.hideout.repository.ReactionRepository import dev.usbharu.hideout.service.ap.APReactionService +import org.jetbrains.exposed.exceptions.ExposedSQLException import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -20,8 +21,9 @@ class ReactionServiceImpl( reactionRepository.save( Reaction(reactionRepository.generateId(), 0, postId, userId) ) - } catch (_: Exception) { + } catch (e: ExposedSQLException) { LOGGER.warn("FAILED Failure to persist reaction information.") + LOGGER.debug("FAILED", e) } } } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/user/UserServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/user/UserServiceImpl.kt index 474fa736..2af93ed6 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/user/UserServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/user/UserServiceImpl.kt @@ -10,6 +10,7 @@ import dev.usbharu.hideout.query.FollowerQueryService import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.repository.UserRepository import dev.usbharu.hideout.service.ap.APSendFollowService +import org.jetbrains.exposed.exceptions.ExposedSQLException import org.springframework.stereotype.Service import java.time.Instant @@ -66,7 +67,7 @@ class UserServiceImpl( ) return try { userRepository.save(userEntity) - } catch (e: Exception) { + } catch (e: ExposedSQLException) { userQueryService.findByUrl(user.url) } }