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
Wrap requests to log JavaScript errors #1292
Comments
From what I gathered, I should wrap |
Could you provide some more information on exactly what you're trying to do and exactly why |
It's been quite some time since I worked on this, but if I remember correctly, What I want to do is to run my own code when server returns something with 200 OK but Restangular itself throws an error. I guess another solution would be that there's an interceptor or a callback that is called when there's a JavaScript error. |
Okay. And to clarify, |
Yes, exactly. |
Of course another option is that the exceptions thrown by Restangular contain the URL in the message. |
Hmmm okay. And you need the URL to correctly send it to Sentry, correct? |
I need the URL to see from the Sentry report where the error actually came from. I can see the line of code, but it would be beneficial to see which REST endpoint was called and with what parameters. |
Ah okay. I believe you are correct that you should wrap the |
Is it possible to somehow wrap all outbound requests and run custom code in case of a JavaScript error? Is there an internal method in Restangular handling HTTP requests that I could replace with my own implementation?
The case is that our application reports JavaScript errors to Sentry. If the API returns a response that Restangular is not able to handle (basically when
Error: Response for getList SHOULD be an array and not an object or something else
happens), we would like to send the API request URL to Sentry as well.I can't do this with
addRequestInterceptor()
because then I would need to set the URL into global context and it would be sent with all the errors that occur until the context is reset. Also, if I send more than one request at the same time, they override each other's context.I can't do this with
setErrorInterceptor()
either, because it's never called if Restangular throws an error.The text was updated successfully, but these errors were encountered: