-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global error handler? #1688
Comments
Why not pull out the exception handling code in Vuex store. You can use |
@piyushchauhan2011 Huge |
ahh like a middleware than can send the thrown exception to |
So I am looking in to this too, indeed in order to send error data to sentry. I came across the following Should hooking in to this solve this? And if so, how do I do this? |
I dove a bit deeper in the code and found the problem. Nuxt allows us to register custom server middleware, but this gets loaded before Nuxt's own middleware. See: https://github.com/nuxt/nuxt.js/blob/75350cdd78d17e565b6c58d6c1aaa00c5146cbae/lib/core/renderer.js#L277-L288 The Connect docs explain:
Meaning that if we define an error middleware (by requesting the |
Using the Nuxt Modules I was able to get Sentry working. Check this gist. You will want to add the A quick explanation what this code does. As I explained in the comment above, the problem is that we cannot add our own error handling because it's loaded before Nuxt's own middleware. What I did is 'backup' the original |
Wow this is awesome @DiederikvandenB I would love to see We have a starter template for a module to get you started quickly: https://github.com/nuxt-community/module-template |
I don't understand why this issue is closed? I don't want to use Sentry. How to handle errors in Nuxt? This is so confusing. I have error that Error template is not catching. You guys can explain how to handle it, please? |
While I agree with the fact that it would be great to have a more straightforward way to handle errors, or maybe better documentation regarding this subject, but the answer to your question is already posted above, @iamdubx. You could either check out my gist, or my module, which you can find here: https://github.com/nuxt-community/sentry-module. If you do not want to use Sentry that is of course perfectly fine. You can just modify the code, specifically this file. Just remove all the references to Sentry/Raven and add your own error handler on what is now rule number 53. Good luck. |
I don't understand why this issue is closed? I also want to know how to handle global errors in Nuxt . |
@DualWield Check this out. |
@DiederikvandenB Thank you. Yes, it seems that can solve this problem.But I dont' know how to (where to) hook the errorMiddleware. Is there something in the document ? |
Check these two lines and this example. Basically what you need to do is create a plugin which hooks on to the @Atinux, would you appreciate a PR for the docs in which I explain the errorMiddleware hook? |
I will more than appreciate @DiederikvandenB :) |
In that case I'll have a look at it tonight! |
Nuxt.js is great. A single "check how this project does it" line within the API docs, though, is not a good documentation. Thanks for working on this issue. |
You guys are rock!!! Just letting you know, sorry for flood. |
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. |
I'm using nuxt.js in our production environment, but i can't find any document about how to capture and analyze exceptions during running
asyncData
ornuxtServerInit
.I suggest to add options like
Vue.config.errorHandler
to nuxt.config.js, this will allow us capture exception, inject request id into responseThe text was updated successfully, but these errors were encountered: