fix: 위시 삭제·복구 onError 에러 처리 보완 - #322
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다. |
📝 WalkthroughWalkthrough위시 삭제 훅(useDeleteWishes)의 성공/에러 처리 흐름이 onSuccess 중심으로 재구성되어 선택 초기화·삭제 모드 종료·토스트가 추가되고 기존 onError 분기가 제거되었습니다. 위시 복구 훅(usePatchWish)의 onError에서는 400 분기가 추가되고 500 전용 분기가 제거되었습니다. Changes위시 삭제 및 복구 에러 처리 개선
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/app/archive/wish/[id]/_hooks/usePatchWish.ts (1)
40-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value로직은 PR 목표에 부합합니다.
400 검증 오류는 리다이렉트 없이 토스트만 표시하고, 403/404/409는 기존과 동일하게 토스트+리다이렉트를 유지하며, 500은 글로벌 핸들러로 위임하도록 정리된 흐름이 맞습니다. 다만
toast.error(clientErrorMessage)호출이 두 분기에서 중복되므로, 상태 코드 배열과 조건부 리다이렉트로 통합할 수 있습니다.♻️ 중복 제거 제안
- if (status === 400) { - toast.error(clientErrorMessage); - } else if (status === 403 || status === 404 || status === 409) { - toast.error(clientErrorMessage); - router.replace(ROUTES.ARCHIVE()); - } + if (status === 400 || status === 403 || status === 404 || status === 409) { + toast.error(clientErrorMessage); + if (status !== 400) { + router.replace(ROUTES.ARCHIVE()); + } + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/app/archive/wish/`[id]/_hooks/usePatchWish.ts around lines 40 - 45, The error handling in usePatchWish duplicates toast.error(clientErrorMessage) across the 400 and 403/404/409 branches. Refactor the status handling in usePatchWish to centralize the shared toast call, using the status checks to decide only whether to redirect with router.replace(ROUTES.ARCHIVE()), while keeping 400 on toast-only and 403/404/409 on toast plus redirect.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/src/app/archive/wish/`[id]/_hooks/usePatchWish.ts:
- Around line 40-45: The error handling in usePatchWish duplicates
toast.error(clientErrorMessage) across the 400 and 403/404/409 branches.
Refactor the status handling in usePatchWish to centralize the shared toast
call, using the status checks to decide only whether to redirect with
router.replace(ROUTES.ARCHIVE()), while keeping 400 on toast-only and
403/404/409 on toast plus redirect.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3484d30f-fb59-435c-aae6-82865455ecc0
📒 Files selected for processing (2)
apps/web/src/app/archive/_hooks/useDeleteWishes.tsapps/web/src/app/archive/wish/[id]/_hooks/usePatchWish.ts
Co-authored-by: soyeong <mb535622@sookmyung.ac.kr>
작업 요약
작업 세부 내용
useDeleteWishes(DELETE /api/v1/wishlists)onError: error => { // TODO }빈 핸들러 제거handleConfirmDelete의finally에서onSuccess로 이동usePatchWish(PATCH /api/v1/wishlists/{wishId})status === 400분기 추가detail메시지를 toast로 표시status === 500분기 삭제 → 5xx는 전역 에러 핸들러에 위임onError가 400/403/404/409 4xx 전부 담당연관 이슈
closes #300
Summary by CodeRabbit