mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 08:32:25 +00:00
fix: raise instead of swallowing on outbound-message path errors
Per reviewer request (chengyongru): raise exceptions on the outbound message path so ChannelManager can trigger retry logic, matching the pattern from commit 98c2f7cc (Weixin channel cleanup). Changes: - _resolve_server_upload_limit_bytes: warning → error (non-fatal config) - _upload_and_send_attachment media upload: raise instead of swallow - _upload_and_send_attachment room send: raise instead of swallow - send_delta stream edit: error + raise after cleanup - weixin _load_state: warning → error (non-fatal state load)
This commit is contained in:
parent
ba1e5036f5
commit
31c45fe798
@ -412,7 +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)
|
self.logger.error("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:
|
||||||
@ -458,8 +458,7 @@ class MatrixChannel(BaseChannel):
|
|||||||
filesize=size_bytes,
|
filesize=size_bytes,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.warning("Media upload failed", exc_info=True)
|
raise
|
||||||
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
|
||||||
@ -478,8 +477,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)
|
raise
|
||||||
return fail
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def send(self, msg: OutboundMessage) -> None:
|
async def send(self, msg: OutboundMessage) -> None:
|
||||||
@ -556,8 +554,9 @@ 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)
|
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:
|
||||||
|
|||||||
@ -208,7 +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)
|
self.logger.error("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