From b60e9f6a1468c85cd5bd5ed72b1587e2ec59a14b Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 6 Oct 2025 20:49:24 +0200 Subject: [PATCH] Preserve tracebacks in ExceptionEvent for more informative crashes. --- src/ircplom/events.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.30.2