Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Extend stack to exc_info #1060

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions raven/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,37 @@ def _get_value(self, exc_type, exc_value, exc_traceback):
'stacktrace': stack_info,
}

@staticmethod
def full_stacktrace(t, v, tb):
class FauxTb(object):
def __init__(self, tb_frame, tb_lineno, tb_next):
self.tb_frame = tb_frame
self.tb_lineno = tb_lineno
self.tb_next = tb_next

def extend_tb(tb):
f = tb.tb_frame
lst = []
while f is not None:
lst.append((f, f.f_lineno))
f = f.f_back
head = tb
for tb_frame, tb_lineno in lst[1:]:
head = FauxTb(tb_frame, tb_lineno, head)
return head

full_tb = extend_tb(tb)
return t, v, full_tb

def capture(self, exc_info=None, **kwargs):
if not exc_info or exc_info is True:
exc_info = sys.exc_info()

if not exc_info:
raise ValueError('No exception found')

exc_info = self.full_stacktrace(*exc_info)

values = []
for exc_info in _chained_exceptions(exc_info):
value = self._get_value(*exc_info)
Expand Down