Nuxe ships a small but complete error-handling system built around theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
NuxeError class. createError constructs a structured error from any input, showError throws it while simultaneously updating the app-wide error state (so your error page component reacts), useError reads the current error as a reactive Ref, and clearError resets the state and optionally navigates away.
NuxeError
NuxeError extends the native Error class with HTTP-aware fields. It is the canonical error type in Nuxe and is recognized by all error utilities.
The HTTP status code associated with the error. Defaults to
500 when not specified.A short human-readable status phrase (e.g.
"Not Found", "Forbidden"). Defaults to "Internal Server Error".The standard
Error.message. Falls back to statusMessage if not provided.An optional longer description intended for display on the error page.
Any additional structured data you want to attach to the error (e.g. validation errors, original response body).
createError
Constructs a NuxeError from a payload object, a plain string, or a native Error.
Signature
Accepts three forms:
NuxeErrorPayloadobject — mapped directly toNuxeErrorfields.string— used asstatusMessage;statusCodedefaults to500.Errorinstance —messageis preserved;statusCodedefaults to500.NuxeErrorinstance — returned as-is without wrapping.
NuxeErrorPayload shape:HTTP status code. Defaults to
500.Short status phrase. Defaults to
"Internal Server Error".The error message. Defaults to
statusMessage when omitted.Longer human-readable description for the error page.
Arbitrary structured data to attach to the error.
showError
Throws a NuxeError and writes it into the app’s reactive error state so that the error page component updates immediately.
Signature
showError accepts the same inputs as createError, wraps them in a NuxeError internally, sets the injected error Ref, and then throws. Because it always throws, TypeScript infers the return type as never — you can use it in places that require a definite code path termination.
useError
Returns the current app-level error as a reactive Ref.
Signature
A
Ref that is null when no error is active and holds the current NuxeError when one has been set via showError. Use this in your error page component to display error details.clearError
Resets the app-level error state. Optionally navigates the user to a different route after clearing.
Signature
A route path to navigate to after the error is cleared. If omitted, the current route is kept.
isNuxeError
A type guard that returns true if the given value is a NuxeError instance (or a structurally compatible plain object with name === 'NuxeError' and a numeric statusCode).
Signature
serializeError / deserializeError
Utilities for converting NuxeError instances to and from plain objects during SSR payload serialization.
serializeError returns null for any value that is not a NuxeError. deserializeError constructs a fresh NuxeError from a plain payload object, restoring the full class prototype chain after JSON deserialization.