goober/modules/unhandledexception.py

19 lines
610 B
Python
Raw Permalink Normal View History

2025-06-22 20:49:07 +02:00
import sys
import traceback
2025-07-23 16:58:21 +02:00
from modules.globalvars import RED, RESET
from modules.volta.main import _
2025-06-22 20:49:07 +02:00
def handle_exception(exc_type, exc_value, exc_traceback, *, context=None):
if issubclass(exc_type, KeyboardInterrupt):
sys.__excepthook__(exc_type, exc_value, exc_traceback)
return
print(f"{RED}=====BEGINNING OF TRACEBACK====={RESET}")
traceback.print_exception(exc_type, exc_value, exc_traceback)
print(f"{RED}========END OF TRACEBACK========{RESET}")
print(f"{RED}{_('unhandled_exception')}{RESET}")
2025-06-22 20:49:07 +02:00
if context:
print(f"{RED}Context: {context}{RESET}")