generated from pricelees/issue-pr-template
[#50] Tosspay API Mocking 서버 구현 #51
@ -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))
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user