-
Notifications
You must be signed in to change notification settings - Fork 1
✨ [Feature] 에러 전역 처리 #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
✨ [Feature] 에러 전역 처리 #321
The head ref may contain hidden characters: "267-feature-\uC5D0\uB7EC-\uC804\uC5ED-\uCC98\uB9AC"
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
2 tasks
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
sunnwave
approved these changes
Feb 6, 2025
wynter24
approved these changes
Feb 6, 2025
Contributor
wynter24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
📝작업 내용
에러 처리 흐름은 다음과 같습니다.
global-error.tsx: 루트 레이아웃 에러 처리not-found.tsx: 404 에러 처리클라이언트 사이드 컴포넌트:
ErrorBoundary: React 런타임 에러 캐치ErrorFallback: 클라이언트 에러 UIErrorHandlingWrapper: React Query와 ErrorBoundary 통합서버 사이드 컴포넌트:
error.tsx: Next.js 서버 컴포넌트 에러 처리ErrorTemplate: 서버 에러 UI 템플릿global-error.tsx: 전역 에러 처리not-found.tsx: 404 페이지쿼리조회나 뮤테이션시 기본적으로 토스트 에러를 제공합니다. (단 이는 고정된 메시지이며 만약 이를 커스텀하고 싶을 땐, 기존 저희가 작성하던 코드 방식대로
onError부분에 토스트 메시지를 작성해주면 해당 부분에서 설정한 토스트 값을 덮어 커스텀할 수 있습니다.)미리보기, 사용방법 및 결과물
클라이언트 사이드 에러
오류가 나는 다른 부분들을 헤치지않고 오류나는 부분만 표시되고 있음

서버 사이드 에러
not found 에러
기타 참고사항
현재 에러 시스템 구현만 해둔 상태라 실제 처리는 각 페이지에서 추가로 진행되어야 합니다.
클라이언트 사이드 에러의 경우 '마이 페이지 - 참여한 모임' 쪽
ClubContents파일에 예시를 작성해두었습니다.이런식으로 에러바운더리로 감시할 부분을
ErrorHandlingWrapper로 감싸서 사용하면 됩니다!서버 사이드 에러의 경우는 각
page.tsx옆에 개별 에러 파일을 생성하면 되는데ErrorTemplate.tsx코드를 만들어두었으니 이를 사용하면 페이지별로 쉽게 커스텀하여 사용할 수 있습니다.예시로 북클럽 생성 페이지 옆에
error.tsx파일 하나 생성해두었습니다.테스트 코드 에러 사항
+++ 추가로 작업하면서 에러 처리 적용으로 @sunnwave 님이 개발하신 프로필 페이지쪽에서 나던 오류가 걸려서 화면이 제대로 보이지 않게 되어서 path값을 통해 사용자 정보를 받던 hook 파일을 임시로 조금 수정해두었는데 이 때문인지
Info.test.tsx에서 테스트 하나가 걸리게 되는 것 같습니다.(로컬에서는 통과되는데 빌드시에만 통과를 못하는 것 같습니다)
리팩토링 하면서 해당 로직이 어떻게 바뀔지 몰라서 우선 통과하지 못한 테스트 코드 부분을 주석처리 해두었는데 리팩토링 이후 다시 테스트해보고 안되면 같이 공유하면 될 것 같습니다!