From 84c11c835e987fc20cc1794b50213e9608eaa585 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Wed, 18 Nov 2026 17:42:47 +0900 Subject: [PATCH] =?UTF-8?q?fix(kis):=20CurrentPriceResponse=EC=9D=98=20out?= =?UTF-8?q?put=20=ED=95=84=EB=93=9C=20null=20=ED=97=88=EC=9A=A9=20?= =?UTF-8?q?=EB=B0=8F=20KIS=20API=20=EC=97=90=EB=9F=AC=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=20=ED=8C=8C=EC=8B=B1=20=EC=98=88=EC=99=B8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/model/StockModels.kt | 8 ++++---- src/main/kotlin/network/KisTradeService.kt | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/model/StockModels.kt b/src/main/kotlin/model/StockModels.kt index cfeb338..91a5f5e 100644 --- a/src/main/kotlin/model/StockModels.kt +++ b/src/main/kotlin/model/StockModels.kt @@ -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 diff --git a/src/main/kotlin/network/KisTradeService.kt b/src/main/kotlin/network/KisTradeService.kt index efc1005..ddd8eb5 100644 --- a/src/main/kotlin/network/KisTradeService.kt +++ b/src/main/kotlin/network/KisTradeService.kt @@ -581,20 +581,18 @@ object KisTradeService { if (response.status.isSuccess()) { val body = response.body() - 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) } }