mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
f26a801775
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
32 lines
896 B
Markdown
32 lines
896 B
Markdown
---
|
|
title: "clearError"
|
|
description: "The clearError composable clears all handled errors."
|
|
links:
|
|
- label: Source
|
|
icon: i-simple-icons-github
|
|
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/error.ts
|
|
size: 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).
|
|
|
|
```js
|
|
// Without redirect
|
|
clearError()
|
|
|
|
// With redirect
|
|
clearError({ redirect: '/homepage' })
|
|
```
|
|
|
|
Errors are set in state using [`useError()`](/docs/api/composables/use-error). 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"}
|