Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions raven/contrib/tornado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,21 @@ def captureException(self, exc_info=None, **kwargs):
def captureMessage(self, message, **kwargs):
return self._capture('captureMessage', message=message, **kwargs)

def write_error(self, status_code, **kwargs):
def log_exception(self, typ, value, tb):
"""Override implementation to report all exceptions to sentry.
log_exception() is added in Tornado v3.1.
"""
rv = super(SentryMixin, self).write_error(status_code, **kwargs)
self.captureException(exc_info=kwargs.get('exc_info'))
rv = super(SentryMixin, self).log_exception(typ, value, tb)
self.captureException(exc_info=(typ, value, tb))
return rv

def send_error(self, status_code=500, **kwargs):
"""Override implementation to report all exceptions to sentry, even
after self.flush() or self.finish() is called, for pre-v3.1 Tornado.
"""
if hasattr(super(SentryMixin, self), 'log_exception'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a huge fan of doing the feature check every single time this is called, but I also dont know what it takes to test for this feature outside of this

If there's a sane way I would definitely appreciate a followup pull request that improves on this ,but otherwise this looks good

return super(SentryMixin, self).send_error(status_code, **kwargs)
else:
rv = super(SentryMixin, self).send_error(status_code, **kwargs)
self.captureException(exc_info=kwargs.get('exc_info'))
return rv