Inspired by the solution posted in #429, I am looking to add error handling for some axios calls.
The code in that solution only throws errors in the browser, so I would like to instead throw a regular nuxt error page. However, the only way I know to do this is using the context.error() function inside asyncData or fetch.
How can I throw an error inside a plugin? Is there a way to get the global context or error handler?
Hi @benosman
It's possible on the client-side only via: $nuxt.error({ statusCode, message })
Example:
window.onNuxtReady(() => {
$nuxt.error({ statusCode: 400, message: 'Teub' })
})
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @benosman
It's possible on the client-side only via:
$nuxt.error({ statusCode, message })Example: