mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 16:42:25 +00:00
fix: replace raise with logger.error + return fail in exception handlers
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).
This commit is contained in:
parent
31c45fe798
commit
4d168c571c
@ -458,7 +458,8 @@ class MatrixChannel(BaseChannel):
|
|||||||
filesize=size_bytes,
|
filesize=size_bytes,
|
||||||
)
|
)
|
||||||
except Exception:
|
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
|
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
|
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:
|
try:
|
||||||
await self._send_room_content(room_id, content)
|
await self._send_room_content(room_id, content)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise
|
self.logger.error("Matrix room content send failed for room_id=%s", room_id, exc_info=True)
|
||||||
|
return fail
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def send(self, msg: OutboundMessage) -> None:
|
async def send(self, msg: OutboundMessage) -> None:
|
||||||
@ -556,7 +558,6 @@ class MatrixChannel(BaseChannel):
|
|||||||
except Exception:
|
except Exception:
|
||||||
self.logger.error("Stream send/edit failed for chat_id=%s", chat_id, exc_info=True)
|
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)
|
await self._stop_typing_keepalive(chat_id, clear_typing=True)
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def _register_event_callbacks(self) -> None:
|
def _register_event_callbacks(self) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user