QuizzesErrors, 404s and Redirects — Concept Check
intermediate
nextjs

Errors, 404s and Redirects — Concept Check

Questions on Errors, 404s and Redirects. Four files and two functions cover every failure path. The subtlety is that notFound() and redirect() work by throwing, which interacts badly with try/catch.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Errors, 404s and Redirects — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a function that fetches data and uses `notFound()` when no data is found. Inside a `try/catch`, it returns a generic error component. What is the likely outcome?

    • AThe page will redirect to a different URL.
    • BThe function will not execute due to syntax error.
    • CThe page displays a generic error instead of a 404.
    • DThe page correctly shows a 404 error.
  2. 2.A developer uses `redirect('/login')` inside a `try/catch` block. What happens if the redirect condition is met?

    • AA syntax error is thrown.
    • BThe redirect is ignored and a generic error is shown.
    • CThe redirect occurs successfully.
    • DThe application crashes.
  3. 3.What happens if `notFound()` is called outside of a `try/catch` block when data is missing?

    • AThe nearest `not-found.tsx` is rendered with a 404 status.
    • BA generic error page is displayed.
    • CThe page redirects to the homepage.
    • DThe application crashes.
  4. 4.A developer sets up a redirect in `next.config.js` from `/old-path` to `/new-path` with `permanent: true`. What status code is sent?

    • A307
    • B200
    • C404
    • D308
  5. 5.If a route exists but the record does not, what message should be displayed according to best practices?

    • APage not found.
    • BThis problem was removed.
    • CAccess denied.
    • DInternal server error.
  6. 6.A developer notices that search engines are indexing error pages. What might be the cause?

    • APermanent redirects set to true.
    • BMiddleware handling redirects.
    • CCorrectly configured 404 pages.
    • DSoft 404s returning a 200 status code.
  7. 7.What is the primary purpose of using `permanentRedirect()` in an application?

    • ATo render a custom error component.
    • BTo send a 308 status for moved URLs.
    • CTo log errors to a monitoring service.
    • DTo temporarily redirect with a 307 status.
  8. 8.Why is it important to distinguish between route and record 404s in your application copy?

    • AThey both result in a 404 status code.
    • BThey are handled by the same error component.
    • CThey do not affect SEO.
    • DThey require different user messages and actions.