From 4d168c571c816f1d0035a9abe4ca0ce0eee144b7 Mon Sep 17 00:00:00 2001 From: Vilius Vystartas Date: Thu, 7 May 2026 07:57:35 +0100 Subject: [PATCH] fix: replace raise with logger.error + return fail in exception handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous version changed return fail/pass to raise, which broke graceful degradation — tests expect upload/content failures to be caught and handled, not propagated. Now logs errors with exc_info=True while preserving existing control flow (return fail for upload/content send, stop typing for stream). --- nanobot/channels/matrix.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py index 28e6197a8..3d9e33c9d 100644 --- a/nanobot/channels/matrix.py +++ b/nanobot/channels/matrix.py @@ -458,7 +458,8 @@ class MatrixChannel(BaseChannel): filesize=size_bytes, ) except Exception: - raise + self.logger.error("Matrix media upload failed for %s", filename, exc_info=True) + return fail upload_response = upload_result[0] if isinstance(upload_result, tuple) else upload_result encryption_info = upload_result[1] if isinstance(upload_result, tuple) and isinstance(upload_result[1], dict) else None @@ -477,7 +478,8 @@ class MatrixChannel(BaseChannel): try: await self._send_room_content(room_id, content) except Exception: - raise + self.logger.error("Matrix room content send failed for room_id=%s", room_id, exc_info=True) + return fail return None async def send(self, msg: OutboundMessage) -> None: @@ -556,7 +558,6 @@ class MatrixChannel(BaseChannel): except Exception: self.logger.error("Stream send/edit failed for chat_id=%s", chat_id, exc_info=True) await self._stop_typing_keepalive(chat_id, clear_typing=True) - raise def _register_event_callbacks(self) -> None: