임동욱 임동욱 08-20
merge: console.error undefined 인자 제거
@c39948a9cf21cf4de2cfbf64237f577edb7e9235
lib/http/backend-fetch.ts
--- lib/http/backend-fetch.ts
+++ lib/http/backend-fetch.ts
@@ -113,9 +113,23 @@
   timeoutMs?: number;
 };
 
-function communicationError(reason: string, detail: unknown): BackendResult<never> {
-  // 실패 상세는 서버 콘솔에만 남기고, 호출부·화면에는 일반화된 메시지만 전달한다.
-  console.error(`[backend-fetch] ${reason}`, detail);
+/**
+ * 실패 상세는 서버 콘솔에만 남기고, 호출부·화면에는 일반화된 메시지만 전달한다.
+ *
+ * 이슈: `detail`이 `undefined`일 때 `console.error(msg, undefined)`로 부르면 안 된다. 콘솔을
+ *   계측하는 개발 도구(예: VS Code 확장 Console Ninja)가 인자를 훑다가
+ *   `Cannot read properties of undefined (reading 'stack')`으로 터지고, 그러면 이 함수가
+ *   값을 돌려주지 못해 `backendFetch`가 결과 대신 예외를 던진다. 인자 자체를 넘기지 않는다.
+ */
+function communicationError(
+  reason: string,
+  detail?: unknown
+): BackendResult<never> {
+  if (detail === undefined) {
+    console.error(`[backend-fetch] ${reason}`);
+  } else {
+    console.error(`[backend-fetch] ${reason}`, detail);
+  }
   return {
     ok: false,
     code: COMMUNICATION_ERROR_CODE,
@@ -201,8 +215,7 @@
     }
 
     return communicationError(
-      `파일 응답의 예상치 못한 HTTP 상태: ${response.status}`,
-      undefined
+      `파일 응답의 예상치 못한 HTTP 상태: ${response.status}`
     );
   }
 
@@ -285,7 +298,7 @@
       };
     }
 
-    return communicationError(`예상치 못한 HTTP 상태: ${response.status}`, undefined);
+    return communicationError(`예상치 못한 HTTP 상태: ${response.status}`);
   }
 
   // 본문 없는 2xx를 허용한 호출은 먼저 글자를 읽어 비었는지 본다 — 비어 있으면 `response.json()`이
@@ -380,8 +393,7 @@
       };
     }
     return communicationError(
-      `업로드 응답의 예상치 못한 HTTP 상태: ${response.status}`,
-      undefined
+      `업로드 응답의 예상치 못한 HTTP 상태: ${response.status}`
     );
   }
 
Add a comment
List