Error 404에러 처리와 서버에러 처리
#177
sgoldenbird
started this conversation in
Development Guidelines
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🧭 404 에러 처리
✅ 라우터 경로가 잘못된 경우 (예:
/abcxyz)path: '*', element: <NotFoundPage />로 처리<NotFoundPage>는 전체 404 이미지, 메인으로 돌아가는 버튼 포함✅ 올바른 경로지만 데이터가 없는 경우 (예:
/list?id=999)throw new Response(..., { status: 404 })로 명시적 에러 발생<ApiErrorBoundary>에서 잡아서 처리하고, 사용자에게 메시지 보여줌→ 즉 "페이지는 존재하지만 컨텐츠 없음", 사용자 입장에서 404 느낌이 나는 상황
→ 이럴 땐 404로 처리하는 게 UX적으로 자연스러움
📌 404 처리 요약
<NotFoundPage><ApiErrorBoundary>🔥 서버 에러 처리 (HTTP 5xx)
✅ 서버 에러 상태코드
✅ 페이지 내 API 요청 중 서버 에러
throw new Response(..., { status: 500 })하면errorElement인<ApiErrorBoundary>가 감지하여 fallback UI 제공✅ 전역 치명적 에러
<GlobalErrorBoundary>에서 최종 fallback 처리/)에errorElement로 지정✅ 의도적으로 서버 에러 테스트할 경우
test-error<GlobalErrorBoundary>에서 fallback📌 서버 에러 처리 요약
/list에서 API 서버 오류<ApiErrorBoundary><GlobalErrorBoundary><ServerErrorPage><GlobalErrorBoundary><ServerErrorPage>Beta Was this translation helpful? Give feedback.
All reactions