-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CircuitBreaker fallback api에서 예외를 던지게 수정 QUZ-122
- Loading branch information
Showing
3 changed files
with
75 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gateway-service/src/main/kotlin/com/grepp/quizy/exception/CircuitBreakerErrorCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.grepp.quizy.exception | ||
|
||
import com.grepp.quizy.common.exception.BaseErrorCode | ||
import com.grepp.quizy.common.exception.ErrorReason | ||
import org.springframework.http.HttpStatus | ||
|
||
enum class CircuitBreakerErrorCode( | ||
private val status: Int, | ||
private val errorCode: String, | ||
private val message: String, | ||
) : BaseErrorCode { | ||
|
||
GAME_UNAVAILABLE(HttpStatus.SERVICE_UNAVAILABLE.value(), "CIRCUIT_BREAKER_503", "게임 서비스를 이용할 수 없습니다."), | ||
MATCHING_UNAVAILABLE(HttpStatus.SERVICE_UNAVAILABLE.value(), "CIRCUIT_BREAKER_503", "매칭 서비스를 이용할 수 없습니다."), | ||
QUIZ_UNAVAILABLE(HttpStatus.SERVICE_UNAVAILABLE.value(), "CIRCUIT_BREAKER_503", "퀴즈 서비스를 이용할 수 없습니다."), | ||
USER_UNAVAILABLE(HttpStatus.SERVICE_UNAVAILABLE.value(), "CIRCUIT_BREAKER_503", "사용자 서비스를 이용할 수 없습니다."), | ||
WS_UNAVAILABLE(HttpStatus.SERVICE_UNAVAILABLE.value(), "CIRCUIT_BREAKER_503", "웹소켓 서비스를 이용할 수 없습니다."), | ||
; | ||
|
||
override val errorReason: ErrorReason | ||
get() = ErrorReason(status, errorCode, message) | ||
} |
42 changes: 42 additions & 0 deletions
42
gateway-service/src/main/kotlin/com/grepp/quizy/exception/CustomCircuitBreakerException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.grepp.quizy.exception | ||
|
||
import com.grepp.quizy.common.exception.WebException | ||
|
||
sealed class CustomCircuitBreakerException(errorCode: CircuitBreakerErrorCode) : WebException(errorCode) { | ||
data object GameServiceUnavailableException : | ||
CustomCircuitBreakerException(CircuitBreakerErrorCode.GAME_UNAVAILABLE) { | ||
private fun readResolve(): Any = GameServiceUnavailableException | ||
|
||
val EXCEPTION: CustomCircuitBreakerException = GameServiceUnavailableException | ||
} | ||
|
||
data object UserServiceUnavailableException : | ||
CustomCircuitBreakerException(CircuitBreakerErrorCode.USER_UNAVAILABLE) { | ||
private fun readResolve(): Any = UserServiceUnavailableException | ||
|
||
val EXCEPTION: CustomCircuitBreakerException = UserServiceUnavailableException | ||
} | ||
|
||
data object QuizServiceUnavailableException : | ||
CustomCircuitBreakerException(CircuitBreakerErrorCode.QUIZ_UNAVAILABLE) { | ||
private fun readResolve(): Any = QuizServiceUnavailableException | ||
|
||
val EXCEPTION: CustomCircuitBreakerException = QuizServiceUnavailableException | ||
} | ||
|
||
data object MatchingServiceUnavailableException : | ||
CustomCircuitBreakerException(CircuitBreakerErrorCode.MATCHING_UNAVAILABLE) { | ||
private fun readResolve(): Any = MatchingServiceUnavailableException | ||
|
||
val EXCEPTION: CustomCircuitBreakerException = MatchingServiceUnavailableException | ||
} | ||
|
||
data object WsUnavailableException : | ||
CustomCircuitBreakerException(CircuitBreakerErrorCode.WS_UNAVAILABLE) { | ||
private fun readResolve(): Any = WsUnavailableException | ||
|
||
val EXCEPTION: CustomCircuitBreakerException = WsUnavailableException | ||
} | ||
} | ||
|
||
|