fix(kis): CurrentPriceResponse의 output 필드 null 허용 및 KIS API 에러 응답 파싱 예외 해결
This commit is contained in:
@@ -249,10 +249,10 @@ data class ExecutionData(
|
||||
|
||||
@Serializable
|
||||
data class CurrentPriceResponse(
|
||||
val rt_cd: String, // 0: 성공, 0 이외: 실패
|
||||
val msg_cd: String,
|
||||
val msg1: String,
|
||||
val output: CurrentPriceOutput
|
||||
val rt_cd: String = "", // 0: 성공, 0 이외: 실패
|
||||
val msg_cd: String = "",
|
||||
val msg1: String = "",
|
||||
val output: CurrentPriceOutput? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -581,20 +581,18 @@ object KisTradeService {
|
||||
|
||||
if (response.status.isSuccess()) {
|
||||
val body = response.body<CurrentPriceResponse>()
|
||||
if (body.rt_cd == "0") {
|
||||
// println("${body.output}")
|
||||
if (body.rt_cd == "0" && body.output != null) {
|
||||
Result.success(body.output)
|
||||
} else {
|
||||
println("API 에러: ${body.msg1}")
|
||||
Result.failure(Exception("API 에러: ${body.msg1}"))
|
||||
println("⚠️ [KIS 현재가 조회 에러] [$stockCode] code: ${body.msg_cd}, msg: ${body.msg1}")
|
||||
Result.failure(Exception("API 에러: ${body.msg1} (code: ${body.msg_cd})"))
|
||||
}
|
||||
} else {
|
||||
println("HTTP 에러: ${response.status}")
|
||||
Result.failure(Exception("HTTP 에러: ${response.status}"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
println("HTTP 에러: ${e.message}")
|
||||
println("❌ [fetchCurrentPrice 예외] [$stockCode]: ${e.message}")
|
||||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user