Static GitHub Issues

[555] How to throw an error outside asyncData and fetch.

prev: context
next: How to import a postcss file with the aliases still working?

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?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c482">#c482</a>)</em></sub></div>