generated from pricelees/issue-pr-template
feat: Tosspay 전용 예외코드 추상화 및 확정 / 취소에서의 예외 정의
This commit is contained in:
parent
1f0dccc194
commit
6087358f9d
@ -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