From 217e59ad96802e0bf0355d0c8ea9b496fb00ec0b Mon Sep 17 00:00:00 2001 From: Krutie Patel Date: Sun, 5 Feb 2023 00:17:05 +1000 Subject: [PATCH] docs: add `useError` composable (#8912) --- docs/3.api/1.composables/use-error.md | 29 +++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/3.api/1.composables/use-error.md b/docs/3.api/1.composables/use-error.md index 906713d005..385b8a6f91 100644 --- a/docs/3.api/1.composables/use-error.md +++ b/docs/3.api/1.composables/use-error.md @@ -1,12 +1,37 @@ +--- +title: "useError" +description: useError composable returns the global Nuxt error that is being handled. +--- + # `useError` -This function will return the global Nuxt error that is being handled. +`useError` composable returns the global Nuxt error that is being handled and it is available on both client and server. ```ts const error = useError() ``` -`useError` sets an error in the state and creates a reactive and SSR-friendly global Nuxt error across components. +`useError` sets an error in the state and creates a reactive as well as SSR-friendly global Nuxt error across components. Nuxt errors have the following properties: + +## Properties + +- **statusCode** + + Type: `Number` + + HTTP response status code + +- **statusMessage** + + Type: `String` + + HTTP response status message + +- **message** + + Type: `String` + + Error message ::ReadMore{link="/docs/getting-started/error-handling"} ::