mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 00:22:31 +00:00
fix: log errors in silent exception handlers (matrix + weixin channels)
The Matrix channel had 4 bare except blocks that silently swallowed
transport errors with no logging — stream send/edit failures, media
upload failures, server config fetch failures, and room content send
failures. The Weixin channel had 1 silent state-load failure.
This mirrors commit 98c2f7cc ('fix(weixin): raise exceptions instead
of silently dropping messages') for the Matrix channel and adds a
warning for the remaining silent catch in Weixin's _load_state.
All failures now log at warning level with exc_info=True so operators
can diagnose intermittent Matrix/Weixin transport issues.
This commit is contained in:
parent
843e96f09d
commit
ba1e5036f5
@ -412,6 +412,7 @@ class MatrixChannel(BaseChannel):
|
|||||||
try:
|
try:
|
||||||
response = await self.client.content_repository_config()
|
response = await self.client.content_repository_config()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.logger.warning("Failed to fetch server upload limit", exc_info=True)
|
||||||
return None
|
return None
|
||||||
upload_size = getattr(response, "upload_size", None)
|
upload_size = getattr(response, "upload_size", None)
|
||||||
if isinstance(upload_size, int) and upload_size > 0:
|
if isinstance(upload_size, int) and upload_size > 0:
|
||||||
@ -457,6 +458,7 @@ class MatrixChannel(BaseChannel):
|
|||||||
filesize=size_bytes,
|
filesize=size_bytes,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.logger.warning("Media upload failed", exc_info=True)
|
||||||
return fail
|
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
|
||||||
@ -476,6 +478,7 @@ 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:
|
||||||
|
self.logger.warning("Failed to send room content to room_id=%s", room_id, exc_info=True)
|
||||||
return fail
|
return fail
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -553,8 +556,8 @@ class MatrixChannel(BaseChannel):
|
|||||||
# we are editing the same message all the time, so only the first time the event id needs to be set
|
# we are editing the same message all the time, so only the first time the event id needs to be set
|
||||||
buf.event_id = response.event_id
|
buf.event_id = response.event_id
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.logger.warning("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)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _register_event_callbacks(self) -> None:
|
def _register_event_callbacks(self) -> None:
|
||||||
|
|||||||
@ -208,6 +208,7 @@ class WeixinChannel(BaseChannel):
|
|||||||
self.config.base_url = base_url
|
self.config.base_url = base_url
|
||||||
return bool(self._token)
|
return bool(self._token)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.logger.warning("Failed to load Weixin account state", exc_info=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _save_state(self) -> None:
|
def _save_state(self) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user