diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2025-08-01 17:02:14 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2025-08-01 20:56:33 -0400 |
| commit | 15c635b873105eda2861430d062ea3f6bdfe9d9b (patch) | |
| tree | f5b17f7aa1388660992e233b3711654aad0cfb0c /python/interaction.py | |
| parent | 24fef31b14b89198185e5edc39ab7e6a7ef2e9ba (diff) | |
Use log_error_for_exception in the Python API to pass tracebacks in the stack trace associated with log messages, instead of creating large mutli-line messages for every exception
Diffstat (limited to 'python/interaction.py')
| -rw-r--r-- | python/interaction.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/python/interaction.py b/python/interaction.py index fe370008..65b8b2a1 100644 --- a/python/interaction.py +++ b/python/interaction.py @@ -27,7 +27,7 @@ from typing import Optional, Callable, List from . import _binaryninjacore as core from .enums import FormInputFieldType, MessageBoxIcon, MessageBoxButtonSet, MessageBoxButtonResult, ReportType from . import binaryview -from .log import log_error +from .log import log_error_for_exception from . import flowgraph from . import mainthread @@ -573,7 +573,7 @@ class InteractionHandler: view = None self.show_plain_text_report(view, title, contents) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_plain_text_report") def _show_markdown_report(self, ctxt, view, title, contents, plaintext): try: @@ -583,7 +583,7 @@ class InteractionHandler: view = None self.show_markdown_report(view, title, contents, plaintext) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_markdown_report") def _show_html_report(self, ctxt, view, title, contents, plaintext): try: @@ -593,7 +593,7 @@ class InteractionHandler: view = None self.show_html_report(view, title, contents, plaintext) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_html_report") def _show_graph_report(self, ctxt, view, title, graph): try: @@ -603,13 +603,13 @@ class InteractionHandler: view = None self.show_graph_report(view, title, flowgraph.CoreFlowGraph(core.BNNewFlowGraphReference(graph))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_graph_report") def _show_report_collection(self, ctxt, title, reports): try: self.show_report_collection(title, ReportCollection(core.BNNewReportCollectionReference(reports))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_report_collection") def _get_text_line_input(self, ctxt, result, prompt, title): try: @@ -619,7 +619,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_text_line_input") def _get_int_input(self, ctxt, result, prompt, title): try: @@ -629,7 +629,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_int_input") def _get_address_input(self, ctxt, result, prompt, title, view, current_address): try: @@ -643,7 +643,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_address_input") def _get_choice_input(self, ctxt, result, prompt, title, choice_buf, count): try: @@ -656,7 +656,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_choice_input") def _get_large_choice_input(self, ctxt, result, prompt, title, choice_buf, count): try: @@ -669,7 +669,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_large_choice_input") def _get_open_filename_input(self, ctxt, result, prompt, ext): try: @@ -679,7 +679,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_open_filename_input") def _get_save_filename_input(self, ctxt, result, prompt, ext, default_name): try: @@ -689,7 +689,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_save_filename_input") def _get_directory_name_input(self, ctxt, result, prompt, default_name): try: @@ -699,7 +699,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_directory_name_input") def _get_checkbox_input(self, ctxt, result, prompt, default_choice): try: @@ -709,7 +709,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_checkbox_input") def _get_form_input(self, ctxt, fields, count, title): try: @@ -776,7 +776,6 @@ class InteractionHandler: ) ) elif fields[i].type == FormInputFieldType.CheckboxFormField: - log_error(fields[i].hasDefault) field_objs.append( CheckboxField( fields[i].prompt, @@ -791,19 +790,19 @@ class InteractionHandler: field_objs[i]._fill_core_result(fields[i]) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_form_input") def _show_message_box(self, ctxt, title, text, buttons, icon): try: return self.show_message_box(title, text, buttons, icon) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_message_box") def _open_url(self, ctxt, url): try: return self.open_url(url) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._open_url") return False def _run_progress_dialog(self, title, can_cancel, task, task_ctxt): @@ -814,7 +813,7 @@ class InteractionHandler: return self.run_progress_dialog(title, can_cancel, py_task) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._run_progress_dialog") return False def show_plain_text_report(self, view, title, contents): |
