[#50] Tosspay API Mocking 서버 구현 #51

Merged
pricelees merged 21 commits from feat/#50 into main 2025-10-02 01:13:07 +00:00
Showing only changes of commit 6087358f9d - Show all commits

View File

@ -0,0 +1,29 @@
package com.sangdol.tosspaymock.exception
import com.sangdol.common.types.web.CommonErrorResponse
import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
private val log: KLogger = KotlinLogging.logger {}
@RestControllerAdvice
class TosspayExceptionHandler {
@ExceptionHandler(value = [TosspayException::class])
fun handleTosspayException(
e: TosspayException
): ResponseEntity<CommonErrorResponse> {
val code = e.errorCode
val name = (code as Enum<*>).name
val message = e.message
log.warn { "[TosspayExceptionHandler] 결제 처리 과정 중 오류 발생: error=${name}, message=$message" }
return ResponseEntity
.status(code.httpStatus.value())
.body(CommonErrorResponse(name, message))
}
}