Nuxt/docs/content/3.api/3.utils/throw-error.md

21 lines
521 B
Markdown
Raw Normal View History

# `throwError`
2022-04-12 08:13:02 +00:00
Nuxt provides a quick and simple way to throw errors.
Within your pages, components and plugins you can use `throwError` to throw an error.
**Parameters:**
- `error`: `string | Error`
```js
throwError("😱 Oh no, an error has been thrown.")
```
2022-04-12 08:13:02 +00:00
The thrown error is set in state using [`useError()`](/api/composables/use-error) to create a reactive and SSR-friendly shared error state across components.
`throwError` calls the `app:error` hook.
::ReadMore{link="/guide/features/error-handling"}
::