Skip to content

Improve the capture of unhandled errors from promises #330

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

Merged
merged 4 commits into from
May 16, 2015

Conversation

joeyespo
Copy link
Contributor

After using the code behind #319 for about a week, we ran into a little problem.

Even though it's recommended that Promise.reject passes in an Error instance, not all 3rd-party libraries do. This lead to production errors with [object Object] as the error message, which wasn't very helpful.

This fixes the problem by creating a new error (for the stack trace), if one wasn't provided, and passing the reason object as extra context.

@mattrobenolt
Copy link
Contributor

So I think we should just handle this inside captureException honestly. In raven-node we just do: https://github.com/getsentry/raven-node/blob/master/lib/client.js#L115-L121

I think that'd be acceptable here as well.

@joeyespo
Copy link
Contributor Author

I tried that originally. You'll still get [object Object] in these cases since some libraries are calling reject with an object.

@joeyespo
Copy link
Contributor Author

I just simplified this a bit by using captureMessage instead of making a new Error. The stack trace was just Ember's stack trace, so that wasn't really helping anyone by sending it to Sentry afterall.

@joostdevries
Copy link

VERY MUCH 👍 on this. One thing I noticed is that the failed promise is actually also propageted to Ember.onerror (at least for my app) so you might need to implement the same logic there.

@mattrobenolt
Copy link
Contributor

I don't have much context about Ember, but since this is isolated to a plugin, it looks fine. I assume someone else will complain if this isn't quite right. :) But seems legit.

mattrobenolt added a commit that referenced this pull request May 16, 2015
Improve the capture of unhandled errors from promises
@mattrobenolt mattrobenolt merged commit b51bc89 into getsentry:master May 16, 2015
@joeyespo
Copy link
Contributor Author

@mattrobenolt Haha, I'm sure someone will. Such is continuous improvement. Thanks!

@joeyespo joeyespo deleted the improve-rsvp-onerror branch May 17, 2015 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants