diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml new file mode 100644 index 0000000..02b915b --- /dev/null +++ b/.idea/git_toolbox_prj.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 03d9549..52ff362 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,7 @@ \ No newline at end of file diff --git a/src/lib/http-client.ts b/src/lib/http-client.ts index be1a7a0..52fb1dc 100644 --- a/src/lib/http-client.ts +++ b/src/lib/http-client.ts @@ -191,10 +191,24 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {}) } return parsed as T; - } catch (err: any) { - // 🔻 여기서 네트워크 레벨 에러 처리 - const code = err?.cause?.code ?? err?.code; + } catch (err: unknown) { + let code: string | undefined; + if (typeof err === "object" && err !== null) { + const anyErr = err as { cause?: unknown; code?: unknown }; + if (anyErr.cause && typeof anyErr.cause === "object") { + const cause = anyErr.cause as { code?: unknown }; + if (typeof cause.code === "string") { + code = cause.code; + } + } + + if (!code && typeof anyErr.code === "string") { + code = anyErr.code; + } + } + + // 🔻 여기서 네트워크 레벨 에러 처리 if (code === "ECONNREFUSED") { // 네트워크 연결 실패 → HttpError(404)로 변환 throw new HttpError(