2022-10-06 09:15:30 +00:00
---
title: "clearError"
description: "The clearError composable clears all handled errors."
2023-10-18 10:59:43 +00:00
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
2022-10-06 09:15:30 +00:00
---
2022-04-06 05:56:08 +00:00
2022-04-11 21:00:43 +00:00
Within your pages, components, and plugins, you can use `clearError` to clear all errors and redirect the user.
**Parameters:**
2022-04-14 08:51:39 +00:00
- `options?: { redirect?: string }`
2022-04-06 05:56:08 +00:00
2022-04-11 21:00:43 +00:00
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
2022-04-14 08:51:39 +00:00
clearError({ redirect: '/homepage' })
2022-04-11 21:00:43 +00:00
```
2022-11-16 10:04:28 +00:00
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.
2022-04-11 21:00:43 +00:00
2023-10-18 10:59:43 +00:00
:read-more{to="/docs/getting-started/error-handling"}