diff --git a/docs/02-app/01-building-your-application/01-routing/05-error-handling.mdx b/docs/02-app/01-building-your-application/01-routing/05-error-handling.mdx index 776760f943eb2..05a4c3db7baa7 100644 --- a/docs/02-app/01-building-your-application/01-routing/05-error-handling.mdx +++ b/docs/02-app/01-building-your-application/01-routing/05-error-handling.mdx @@ -109,7 +109,7 @@ You could also use the returned state to display a toast message from the client ### Handling Expected Errors from Server Components -When fetching data inside of a Server Component, you can use the response to conditionally render an error message or `redirect`. +When fetching data inside of a Server Component, you can use the response to conditionally render an error message or [`redirect`](/docs/app/building-your-application/routing/redirecting#redirect-function). ```tsx filename="app/page.tsx" switcher export default async function Page() { @@ -137,37 +137,6 @@ export default async function Page() { } ``` -Or - -```tsx filename="app/page.tsx" switcher -import { redirect } from 'next/navigation' - -export default async function Page() { - const res = await fetch(`https://...`) - const data = await res.json() - - if (!res.ok) { - redirect("/dashboard") - } - - return '...' -} -``` -```jsx filename="app/page.js" switcher -import { redirect } from 'next/navigation' - -export default async function Page() { - const res = await fetch(`https://...`) - const data = await res.json() - - if (!res.ok) { - redirect('/dashboard') - } - - return '...' -} -``` - ## Uncaught Exceptions Uncaught exceptions are unexpected errors that indicate bugs or issues that should not occur during the normal flow of your application. These should be handled by throwing errors, which will then be caught by error boundaries.