임동욱 임동욱 08-20
chore: 콘텐츠 쓰기 실패 시 보낸 본문을 그대로 찍는다
백엔드 로그를 볼 수 없어 무엇을 보냈는지 확인할 방법이 없었다. 수정은 JSON을
Swagger Request body에 붙여 넣을 수 있는 모양으로, 등록은 form 문자열로 남긴다.

Co-Authored-By: Claude Opus 5 
@8463b723ee3fa609d096af2162b44c8c17b5979f
lib/data/repositories/content-repository.ts
--- lib/data/repositories/content-repository.ts
+++ lib/data/repositories/content-repository.ts
@@ -343,6 +343,23 @@
   });
 
   if (!result.ok) {
+    // 백엔드 로그를 볼 수 없어, 무엇을 보냈는지 여기서 그대로 남긴다. JSON 본문은 Swagger의
+    // Request body에 그대로 붙여 넣을 수 있는 모양으로 찍는다.
+    console.error(
+      [
+        `[contents] ${method} ${path} 실패 (code ${result.code}: ${result.message})`,
+        body === undefined ? null : `body(JSON):\n${JSON.stringify(body, null, 2)}`,
+        form === undefined
+          ? null
+          : `form:\n${new URLSearchParams(
+              Object.entries(form).flatMap(([key, value]) =>
+                value === undefined ? [] : [[key, String(value)] as [string, string]]
+              )
+            ).toString()}`,
+      ]
+        .filter(Boolean)
+        .join('\n')
+    );
     throw new BackendRequestError(result);
   }
 
Add a comment
List