From 77f1ed22f2148c169ee4c75788e7bdd82a7c38a1 Mon Sep 17 00:00:00 2001 From: 101 Date: Tue, 27 Feb 2024 16:43:31 +0900 Subject: [PATCH] =?UTF-8?q?errorMap=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VersionMismatchException 이 아닌 다른 예외는 ExecuteFailedException으로 맵핑하여 처리 --- .../daemawiki/domain/content/service/AddContentTable.java | 4 +++- .../com/example/daemawiki/domain/info/service/UpdateInfo.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/daemawiki/domain/content/service/AddContentTable.java b/src/main/java/com/example/daemawiki/domain/content/service/AddContentTable.java index 395017a6..027d5639 100644 --- a/src/main/java/com/example/daemawiki/domain/content/service/AddContentTable.java +++ b/src/main/java/com/example/daemawiki/domain/content/service/AddContentTable.java @@ -8,6 +8,7 @@ import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; import com.example.daemawiki.domain.revision.model.type.RevisionType; import com.example.daemawiki.global.exception.h400.VersionMismatchException; +import com.example.daemawiki.global.exception.h500.ExecuteFailedException; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -64,7 +65,8 @@ public Mono execute(AddContentRequest request) { .type(RevisionType.UPDATE) .documentId(request.documentId()) .title(document.getTitle()) - .build())); + .build())) + .onErrorMap(e -> e instanceof VersionMismatchException ? e : ExecuteFailedException.EXCEPTION); } } diff --git a/src/main/java/com/example/daemawiki/domain/info/service/UpdateInfo.java b/src/main/java/com/example/daemawiki/domain/info/service/UpdateInfo.java index f42b701c..de60185d 100644 --- a/src/main/java/com/example/daemawiki/domain/info/service/UpdateInfo.java +++ b/src/main/java/com/example/daemawiki/domain/info/service/UpdateInfo.java @@ -7,6 +7,7 @@ import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; import com.example.daemawiki.domain.revision.model.type.RevisionType; import com.example.daemawiki.global.exception.h400.VersionMismatchException; +import com.example.daemawiki.global.exception.h500.ExecuteFailedException; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -36,7 +37,8 @@ public Mono execute(UpdateInfoRequest request) { .type(RevisionType.UPDATE) .documentId(request.documentId()) .title(document.getTitle()) - .build())); + .build())) + .onErrorMap(e -> e instanceof VersionMismatchException ? e : ExecuteFailedException.EXCEPTION); } }