From 22f41dadedd179958fbaf0eb4337b44b28873794 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 18 Mar 2026 10:42:43 -0700 Subject: [PATCH] fix: send error details to user in gateway outer exception handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, if an error occurred during response processing in _process_message_background (e.g. during extract_media, send, or any uncaught exception from the handler), the error was only logged to server console and the user was left with radio silence — typing indicator stops but no message arrives. Now the outer except block attempts to send the error type and detail (truncated to 300 chars) to the user's chat, matching the format already used by the inner handler in gateway/run.py. Co-authored-by: Test --- gateway/platforms/base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index 8c43c900..a7a809bb 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -1099,6 +1099,22 @@ class BasePlatformAdapter(ABC): print(f"[{self.name}] Error handling message: {e}") import traceback traceback.print_exc() + # Send the error to the user so they aren't left with radio silence + try: + error_type = type(e).__name__ + error_detail = str(e)[:300] if str(e) else "no details available" + _thread_metadata = {"thread_id": event.source.thread_id} if event.source.thread_id else None + await self.send( + chat_id=event.source.chat_id, + content=( + f"Sorry, I encountered an error ({error_type}).\n" + f"{error_detail}\n" + "Try again or use /reset to start a fresh session." + ), + metadata=_thread_metadata, + ) + except Exception: + pass # Last resort — don't let error reporting crash the handler finally: # Stop typing indicator typing_task.cancel()