스킬 정리 및 리팩토링
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { KisCredentialInput } from "@/lib/kis/config";
|
||||
import { getKisConfig } from "@/lib/kis/config";
|
||||
import { buildKisErrorDetail } from "@/lib/kis/error-codes";
|
||||
import { getKisAccessToken } from "@/lib/kis/token";
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,11 @@ export async function kisGet<TOutput>(
|
||||
const payload = tryParseKisEnvelope<TOutput>(rawText);
|
||||
|
||||
if (!response.ok) {
|
||||
const detail = payload.msg1 || rawText.slice(0, 200);
|
||||
const detail = buildKisErrorDetail({
|
||||
message: payload.msg1,
|
||||
msgCode: payload.msg_cd,
|
||||
extraMessages: payload.msg1 ? [] : [rawText.slice(0, 200)],
|
||||
});
|
||||
throw new Error(
|
||||
detail
|
||||
? `KIS API 요청 실패 (${response.status}): ${detail}`
|
||||
@@ -66,7 +71,10 @@ export async function kisGet<TOutput>(
|
||||
}
|
||||
|
||||
if (payload.rt_cd && payload.rt_cd !== "0") {
|
||||
const detail = [payload.msg1, payload.msg_cd].filter(Boolean).join(" / ");
|
||||
const detail = buildKisErrorDetail({
|
||||
message: payload.msg1,
|
||||
msgCode: payload.msg_cd,
|
||||
});
|
||||
throw new Error(detail || "KIS API 비즈니스 오류가 발생했습니다.");
|
||||
}
|
||||
|
||||
@@ -112,7 +120,11 @@ export async function kisPost<TOutput>(
|
||||
const payload = tryParseKisEnvelope<TOutput>(rawText);
|
||||
|
||||
if (!response.ok) {
|
||||
const detail = payload.msg1 || rawText.slice(0, 200);
|
||||
const detail = buildKisErrorDetail({
|
||||
message: payload.msg1,
|
||||
msgCode: payload.msg_cd,
|
||||
extraMessages: payload.msg1 ? [] : [rawText.slice(0, 200)],
|
||||
});
|
||||
throw new Error(
|
||||
detail
|
||||
? `KIS API 요청 실패 (${response.status}): ${detail}`
|
||||
@@ -121,7 +133,10 @@ export async function kisPost<TOutput>(
|
||||
}
|
||||
|
||||
if (payload.rt_cd && payload.rt_cd !== "0") {
|
||||
const detail = [payload.msg1, payload.msg_cd].filter(Boolean).join(" / ");
|
||||
const detail = buildKisErrorDetail({
|
||||
message: payload.msg1,
|
||||
msgCode: payload.msg_cd,
|
||||
});
|
||||
throw new Error(detail || "KIS API 비즈니스 오류가 발생했습니다.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user