BaseObject: log file and line number for uncaught exceptions

This commit is contained in:
Aleix Conchillo Flaqué
2025-12-16 17:29:14 -08:00
parent 5b30f1b1ef
commit db983cb693

View File

@@ -13,6 +13,7 @@ and async cleanup for all Pipecat components.
import asyncio
import inspect
import traceback
from abc import ABC
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
@@ -187,7 +188,11 @@ class BaseObject(ABC):
else:
handler(self, *args, **kwargs)
except Exception as e:
logger.error(f"Exception in event handler {event_name}: {e}")
tb = traceback.extract_tb(e.__traceback__)
last = tb[-1]
logger.error(
f"Uncaught exception in event handler '{event_name}' ({last.filename}:{last.lineno}): {e}"
)
def _event_task_finished(self, task: asyncio.Task):
"""Clean up completed event handler tasks.