home · contact · privacy
Preserve tracebacks in ExceptionEvent for more informative crashes.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 6 Oct 2025 18:49:24 +0000 (20:49 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 6 Oct 2025 18:49:24 +0000 (20:49 +0200)
src/ircplom/events.py

index 9dac06b2e0468a8dd17a1e39c5505053ada7a6b2..295baa274e0ad0b4a98aa0196e4e4a61f801ee57 100644 (file)
@@ -2,6 +2,7 @@
 from abc import abstractmethod, ABC
 from dataclasses import dataclass
 from queue import SimpleQueue, Empty as QueueEmpty
+from sys import exception as sys_exception
 from threading import Thread
 from typing import Any, Iterator, Literal, Self
 
@@ -56,7 +57,12 @@ class CrashingException(BaseException):
 @dataclass
 class ExceptionEvent(Event):
     'To deliver Exception to main loop for handling.'
-    exception: CrashingException
+
+    def __init__(self, e: CrashingException, *args, **kwargs):
+        tracebackable = sys_exception()
+        self.exception = e.with_traceback(tracebackable.__traceback__
+                                          if tracebackable else None)
+        super().__init__(*args, **kwargs)
 
 
 @dataclass