Skip to content

Commit

Permalink
Convert methods to private methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Dysput committed Oct 29, 2024
1 parent b9f21a3 commit 2d5354a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backtracepython/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
self.source_path_dict = {}
self.attachments = []

stack_trace = self.generate_stack_trace()
stack_trace = self.__generate_stack_trace()

attributes, annotations = attribute_manager.get()
attributes.update({"error.type": "Exception"})
Expand Down Expand Up @@ -56,14 +56,14 @@ def set_exception(self, garbage, ex_value, ex_traceback):

faulting_thread = self.report["threads"][fault_thread_id]

faulting_thread["stack"] = self.convert_stack_trace(
self.traverse_exception_stack(ex_traceback), False
faulting_thread["stack"] = self.__convert_stack_trace(
self.__traverse_exception_stack(ex_traceback), False
)
faulting_thread["fault"] = True
self.faulting_thread_id = fault_thread_id
self.report["mainThread"] = self.faulting_thread_id

def generate_stack_trace(self):
def __generate_stack_trace(self):
current_frames = sys._current_frames()
threads = {}
for thread in threading.enumerate():
Expand All @@ -72,8 +72,8 @@ def generate_stack_trace(self):
thread_id = str(thread.ident)
threads[thread_id] = {
"name": thread.name,
"stack": self.convert_stack_trace(
self.traverse_process_thread_stack(thread_frame), is_main_thread
"stack": self.__convert_stack_trace(
self.__traverse_process_thread_stack(thread_frame), is_main_thread
),
"fault": is_main_thread,
}
Expand All @@ -82,21 +82,21 @@ def generate_stack_trace(self):

return threads

def traverse_exception_stack(self, traceback):
def __traverse_exception_stack(self, traceback):
stack = []
while traceback:
stack.append({"frame": traceback.tb_frame, "line": traceback.tb_lineno})
traceback = traceback.tb_next
return reversed(stack)

def traverse_process_thread_stack(self, thread_frame):
def __traverse_process_thread_stack(self, thread_frame):
stack = []
while thread_frame:
stack.append({"frame": thread_frame, "line": thread_frame.f_lineno})
thread_frame = thread_frame.f_back
return stack

def convert_stack_trace(self, thread_stack_trace, skip_backtrace_module):
def __convert_stack_trace(self, thread_stack_trace, skip_backtrace_module):
stack_trace = []

for thread_stack_frame in thread_stack_trace:
Expand Down

0 comments on commit 2d5354a

Please sign in to comment.