Skip to content

Comments

[Qnrr 522] mutation error handling#149

Open
aken-you wants to merge 6 commits intodevelopfrom
QNRR-522-error-handling
Open

[Qnrr 522] mutation error handling#149
aken-you wants to merge 6 commits intodevelopfrom
QNRR-522-error-handling

Conversation

@aken-you
Copy link
Contributor

☘️ 작업 내용

이전 PR #145 이랑 다른 점은 startTransition 적용한 거 말곤 동일합니다.

@aken-you aken-you changed the title [Qnrr 522] error handling [Qnrr 522] mutation error handling Sep 21, 2025
Comment on lines +34 to +36
startTransition(() => {
router.refresh(); // 서버 컴포넌트들을 다시 렌더링
reset(); // 에러 상태 초기화
Copy link
Contributor Author

Choose a reason for hiding this comment

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

router.refresh 메서드가 비동기적으로 동작하여, 서버 컴포넌트를 다시 렌더링하지 못하는 문제가 있었어요.
refresh 메서드가 promise를 반환하지 않기 때문에 async await을 사용할 수 없었어요.
그래서 startTransition을 써서 refresh, reset 작업의 우선순위를 뒤로 늦췄어요. refresh 실행한 다음에 reset이 일어난다 까지는 찾지 못했으나, React 내부적으로 refresh가 reset 작업보다 먼저 처리하는 것 같아요.
참고 블로그

startTransition의 콜백 안에 두 메서드 다 넣는 경우도 있고, reset 만 넣는 경우도 있었어요.

@de24world de24world requested a review from Copilot October 27, 2025 19:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements comprehensive error handling for mutations across the application, adding specific error code checks and user-facing alert messages. The main addition from PR #145 is the use of startTransition in the error boundary component.

  • Added error handlers to mutations that check for specific API error codes and display appropriate user messages
  • Created a new error boundary component with startTransition for improved error recovery
  • Integrated isApiError helper throughout mutation hooks to type-check errors before handling

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/features/my-page/model/use-update-user-profile-mutation.ts Added onError handler for duplicate interests (MPR001) and missing member (MEM001) errors
src/features/auth/model/use-auth-mutation.ts Added onError handler for duplicate member registration (DUPLICATE_MEMBER)
src/entities/user/model/use-user-profile-query.ts Added error handling for auto-matching mutation with study application and member existence checks
src/entities/review/model/use-review-query.ts Added onError handler for duplicate reviews (CMM001) and missing study/member (CMM003)
app/error.tsx Created error boundary component with startTransition-wrapped recovery actions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -16,6 +17,13 @@ export const useSignUpMutation = () => {
{ name: string; imageExtension: string }
>({
mutationFn: (data: any) => signUp(data),
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The parameter type is specified as any, which defeats TypeScript's type safety. Define a proper type for the signup data or use the existing types from your API layer.

Suggested change
mutationFn: (data: any) => signUp(data),
mutationFn: (data: { name: string; imageExtension: string }) => signUp(data),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant