diff --git a/docs/content/3.docs/1.usage/8.error-handling.md b/docs/content/3.docs/1.usage/8.error-handling.md index 5a9ec02fd0..81a328ca9f 100644 --- a/docs/content/3.docs/1.usage/8.error-handling.md +++ b/docs/content/3.docs/1.usage/8.error-handling.md @@ -88,3 +88,32 @@ You can call this function at any point on client-side, or (on server side) dire * `function clearError (redirect?: string): Promise` This function will clear the currently handled Nuxt error. It also takes an optional path to redirect to (for example, if you want to navigate to a 'safe' page). + +## Rendering errors within your app + +Nuxt also provides a `` component that allows you to handle client-side errors within your app, without replacing your entire site with an error page. + +This component is responsible for handling errors that occur within its default slot. On client-side, it will prevent the error from bubbling up to the top level, and will render the `#error` slot instead. + +The `#error` slot will receive `error` as a prop. (If you set `error = null` it will trigger re-rendering the default slot; you'll need to ensure that the error is fully resolved first or the error slot will just be rendered a second time.) + +::alert{type="info"} +If you navigate to another route, the error will be cleared automatically. +:: + +### Example + +```vue [pages/index.vue] + +``` diff --git a/examples/with-errors/app.vue b/examples/with-errors/app.vue index 8632613624..f6b2aae612 100644 --- a/examples/with-errors/app.vue +++ b/examples/with-errors/app.vue @@ -21,6 +21,9 @@ function triggerError () { Home + + Other + 404 @@ -36,6 +39,8 @@ function triggerError () { + +