Fatal vs non-fatal createError in Nuxt 3: deciding when the error page should take over
0 reputation · 12 Sept 2021, 09:26 UTC
A Nuxt 3 app needs to surface failures usefully without turning every problem into a full-screen interruption. The framework ships no notification system, so the nearest documented lever is error handling: showError or createError with fatal: true renders the app-wide error.vue page, while non-fatal errors are left for local handling, and useAsyncData and useFetch expose an error ref that can be rendered inline in the affected component.
The constraint is that a fatal error replaces the entire route tree, so component state is lost and recovery happens app-wide through clearError. Production builds also replace statusMessage with a generic message, so custom context has to travel in the error's data property. Because exact non-fatal behavior has shifted across Nuxt 3 minor releases, any policy should be validated against the framework version in use.
- Which failure classes, such as expired sessions, 404 states, or transient fetch errors, justify a fatal error versus inline handling through the
errorref? - How should recovery be structured with
clearErrorso users land on a meaningful route after a fatal error? - Where should error context live, given that production sanitizes
statusMessage?