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
... | ... | @@ -343,6 +343,23 @@ |
| 343 | 343 |
}); |
| 344 | 344 |
|
| 345 | 345 |
if (!result.ok) {
|
| 346 |
+ // 백엔드 로그를 볼 수 없어, 무엇을 보냈는지 여기서 그대로 남긴다. JSON 본문은 Swagger의 |
|
| 347 |
+ // Request body에 그대로 붙여 넣을 수 있는 모양으로 찍는다. |
|
| 348 |
+ console.error( |
|
| 349 |
+ [ |
|
| 350 |
+ `[contents] ${method} ${path} 실패 (code ${result.code}: ${result.message})`,
|
|
| 351 |
+ body === undefined ? null : `body(JSON):\n${JSON.stringify(body, null, 2)}`,
|
|
| 352 |
+ form === undefined |
|
| 353 |
+ ? null |
|
| 354 |
+ : `form:\n${new URLSearchParams(
|
|
| 355 |
+ Object.entries(form).flatMap(([key, value]) => |
|
| 356 |
+ value === undefined ? [] : [[key, String(value)] as [string, string]] |
|
| 357 |
+ ) |
|
| 358 |
+ ).toString()}`, |
|
| 359 |
+ ] |
|
| 360 |
+ .filter(Boolean) |
|
| 361 |
+ .join('\n')
|
|
| 362 |
+ ); |
|
| 346 | 363 |
throw new BackendRequestError(result); |
| 347 | 364 |
} |
| 348 | 365 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?