Skip to content

fix: 위시 삭제·복구 onError 에러 처리 보완 - #322

Merged
soyeong0115 merged 3 commits into
devfrom
fix/300-wish-error-handling
Jul 14, 2026
Merged

fix: 위시 삭제·복구 onError 에러 처리 보완#322
soyeong0115 merged 3 commits into
devfrom
fix/300-wish-error-handling

Conversation

@soyeong0115

@soyeong0115 soyeong0115 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • 위시 삭제·복구 onError 에러 처리 보완

작업 세부 내용

useDeleteWishes (DELETE /api/v1/wishlists)

  • onError: error => { // TODO } 빈 핸들러 제거
    • 빈 핸들러가 전역 에러 fallback을 막아 삭제 실패가 silent하게 처리되던 문제 해소
    • 전역 에러 net이 generic 토스트 및 5xx 처리
  • 삭제 모드·선택 상태 초기화를 handleConfirmDeletefinally에서 onSuccess로 이동
    • 기존: API 응답 전 즉시 초기화 → 실패해도 선택 항목이 날아감
    • 변경: 삭제 성공 후 초기화 → 실패 시 선택 상태 유지, 재시도 가능

usePatchWish (PATCH /api/v1/wishlists/{wishId})

  • status === 400 분기 추가
    • 기존엔 400이 개별·전역 모두에서 처리되지 않아 silent 실패
    • 서버 detail 메시지를 toast로 표시
  • status === 500 분기 삭제 → 5xx는 전역 에러 핸들러에 위임
  • 잘못 복사된 토너먼트 관련 주석 제거
  • 결과적으로 onError가 400/403/404/409 4xx 전부 담당

연관 이슈

closes #300

Summary by CodeRabbit

  • Bug Fixes
    • 위시 삭제 완료 시 선택 항목이 자동으로 초기화되고, 삭제 모드가 종료되며, 성공 알림이 표시되도록 개선되었습니다.
    • 위시 수정 실패 시 상태 코드에 따라 더 적절한 오류 안내가 표시됩니다. 특히 잘못된 요청에 대한 메시지가 추가되었고, 접근/존재하지 않는 항목은 기존처럼 목록으로 돌아갑니다.

@soyeong0115 soyeong0115 self-assigned this Jul 9, 2026
@soyeong0115 soyeong0115 added the fix Something isn't working label Jul 9, 2026
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
depromeet Ready Ready Preview, Comment Jul 14, 2026 12:12pm

@github-actions
github-actions Bot requested review from iOdiO89 and kanghaeun July 9, 2026 14:35
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

위시 삭제 훅(useDeleteWishes)의 성공/에러 처리 흐름이 onSuccess 중심으로 재구성되어 선택 초기화·삭제 모드 종료·토스트가 추가되고 기존 onError 분기가 제거되었습니다. 위시 복구 훅(usePatchWish)의 onError에서는 400 분기가 추가되고 500 전용 분기가 제거되었습니다.

Changes

위시 삭제 및 복구 에러 처리 개선

Layer / File(s) Summary
위시 삭제 onSuccess 흐름 및 onError 제거
apps/web/src/app/archive/_hooks/useDeleteWishes.ts
import에서 isAxiosError 제거, onSuccess에 선택 초기화·삭제 모드 종료·성공 토스트 추가, handleConfirmDelete를 단순화해 mutation 호출만 수행하도록 변경, 기존 onError 분기 삭제.
위시 복구 onError 상태 코드 분기 조정
apps/web/src/app/archive/wish/[id]/_hooks/usePatchWish.ts
onError에 400 처리(clientErrorMessage 토스트) 추가, 403/404/409 처리는 유지, 500 전용 토스트 분기 제거.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • TeamPiKi/PiKi-Client#88: 위시 삭제 훅의 성공 시점 상태 초기화/토스트 및 삭제 호출 흐름 변경과 동일한 삭제 기능 코드 경로를 다룸.

Suggested reviewers: kanghaeun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 위시 삭제·복구의 onError 처리 개선이라는 핵심 변경을 잘 요약합니다.
Linked Issues check ✅ Passed 삭제 onError 제거와 복구 PATCH의 400 추가·500 제거가 요구사항과 일치하고, 새로고침은 전역 처리로 허용됩니다.
Out of Scope Changes check ✅ Passed 변경 내용은 삭제·복구 에러 처리 보완 범위 안에 있으며, 별도 무관한 수정은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/300-wish-error-handling

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between ef66bef and 2d4c785.

📒 Files selected for processing (2)
  • apps/web/src/app/archive/_hooks/useDeleteWishes.ts
  • apps/web/src/app/archive/wish/[id]/_hooks/usePatchWish.ts

Comment thread apps/web/src/app/archive/wish/[id]/_hooks/usePatchWish.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

위시 삭제·새로고침·복구 에러 대응

2 participants