Nuxt/docs/3.api/3.utils/clear-error.md
Sébastien Chopin f26a801775
docs: update to new website (#23743)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
2023-10-18 12:59:43 +02:00

896 B

title description links
clearError The clearError composable clears all handled errors.
label icon to size
Source i-simple-icons-github https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/error.ts xs

clearError

Within your pages, components, and plugins, you can use clearError to clear all errors and redirect the user.

Parameters:

  • options?: { redirect?: string }

You can provide an optional path to redirect to (for example, if you want to navigate to a 'safe' page).

// Without redirect
clearError()

// With redirect
clearError({ redirect: '/homepage' })

Errors are set in state using useError(). The clearError composable will reset this state and calls the app:error:cleared hook with the provided options.

:read-more{to="/docs/getting-started/error-handling"}