From: Christian Heller Date: Mon, 6 Oct 2025 18:49:24 +0000 (+0200) Subject: Preserve tracebacks in ExceptionEvent for more informative crashes. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/edit?a=commitdiff_plain;h=b60e9f6a1468c85cd5bd5ed72b1587e2ec59a14b;p=ircplom Preserve tracebacks in ExceptionEvent for more informative crashes. --- diff --git a/src/ircplom/events.py b/src/ircplom/events.py index 9dac06b..295baa2 100644 --- a/src/ircplom/events.py +++ b/src/ircplom/events.py @@ -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