useStatamicPageErrorHandler

Gitlab
Handles errors for Statamic page requests and triggers appropriate error responses.

Usage

The useStatamicPageErrorHandler composable is used to handle errors for Statamic page requests.

It will automatically trigger the nuxt-statamic:error hook before throwing a fatal 404 error. It's designed to handle page-not-found scenarios in a consistent way across the application.

Basic example

pages/blogs/[...slug].vue
<script setup lang="ts">
const { 
data
,
error
} = await
useStatamicPage
();
useStatamicPageErrorHandler
(
error
);
</script>

Type Definition

function 
useStatamicPageErrorHandler
(
requestError
:
MaybeRefOrGetter
<
NuxtError
| undefined>,
): void

API Reference

Params

requestError
MaybeRefOrGetter<NuxtError | undefined>
A ref, getter, or direct value containing a NuxtError or undefined

Return Value

void
Will throw a fatal 404 error when requestError has a value

Changelog