NuxtN
Nuxt3y ago
rd

Client side error handling

I'm having trouble handling errors on the client side of an SSR app. They seem to handle fine on the server. In my setup of my "product" page I have the following:

if (!product) {
  throw createError({ statusCode: 404, statusMessage: 'Product not found' });
}


So if I navigate to the URL /shop/some-product-that-doesnt-exist as the initial server rendered route and product above is false, the server handles the error and Nuxt correctly shows my ~/error.vue component. However if I click on a <NuxtLink> to the same location on the client side, nothing happens, error.vue is not rendered, and the console shows:

Uncaught (in promise) Error: Product not found


I've read the error handling docs several times but can't work out what I'm doing wrong, any ideas? Thanks!
Was this page helpful?