Improve bot error bubble uo along with a few other spots

This commit is contained in:
Jack Kingsman
2026-03-09 00:41:07 -07:00
parent b5c4413e63
commit c3d7b8f79a
7 changed files with 28 additions and 21 deletions

View File

@@ -130,8 +130,8 @@ class BotModule(FanoutModule):
except asyncio.TimeoutError:
logger.warning("Bot '%s' execution timed out", self.name)
return
except Exception as e:
logger.warning("Bot '%s' execution error: %s", self.name, e)
except Exception:
logger.exception("Bot '%s' execution error", self.name)
return
if response and self._active:

View File

@@ -90,8 +90,8 @@ def execute_bot_code(
try:
# Execute the user's code to define the bot function
exec(code, namespace)
except Exception as e:
logger.warning("Bot code compilation failed: %s", e)
except Exception:
logger.exception("Bot code compilation failed")
return None
# Check if bot function was defined
@@ -172,8 +172,8 @@ def execute_bot_code(
logger.debug("Bot function returned unsupported type: %s", type(result))
return None
except Exception as e:
logger.warning("Bot function execution failed: %s", e)
except Exception:
logger.exception("Bot function execution failed")
return None
@@ -249,10 +249,10 @@ async def _send_single_bot_message(
logger.warning("Cannot send bot response: no destination")
return # Don't update timestamp if we didn't send
except HTTPException as e:
logger.error("Bot failed to send response: %s", e.detail)
logger.error("Bot failed to send response: %s", e.detail, exc_info=True)
return # Don't update timestamp on failure
except Exception as e:
logger.error("Bot failed to send response: %s", e)
except Exception:
logger.exception("Bot failed to send response")
return # Don't update timestamp on failure
# Update last send time after successful send

View File

@@ -89,7 +89,13 @@ class BaseMqttPublisher(ABC):
try:
await self._client.publish(topic, json.dumps(payload), retain=retain)
except Exception as e:
logger.warning("%s publish failed on %s: %s", self._log_prefix, topic, e)
logger.warning(
"%s publish failed on %s: %s",
self._log_prefix,
topic,
e,
exc_info=True,
)
self.connected = False
# Wake the connection loop so it exits the wait and reconnects
self._settings_version += 1
@@ -223,6 +229,7 @@ class BaseMqttPublisher(ABC):
self._log_prefix,
e,
backoff,
exc_info=True,
)
try:

View File

@@ -135,4 +135,4 @@ async def _publish_community_packet(
await publisher.publish(topic, packet)
except Exception as e:
logger.warning("Community MQTT broadcast error: %s", e)
logger.warning("Community MQTT broadcast error: %s", e, exc_info=True)

View File

@@ -47,8 +47,8 @@ async def _startup_radio_connect_and_setup() -> None:
logger.info("Connected to radio")
else:
logger.warning("Failed to connect to radio on startup")
except Exception as e:
logger.warning("Failed to connect to radio on startup: %s", e)
except Exception:
logger.exception("Failed to connect to radio on startup")
@asynccontextmanager
@@ -72,8 +72,8 @@ async def lifespan(app: FastAPI):
try:
await fanout_manager.load_from_db()
except Exception as e:
logger.warning("Failed to start fanout modules: %s", e)
except Exception:
logger.exception("Failed to start fanout modules")
startup_radio_task = asyncio.create_task(_startup_radio_connect_and_setup())
app.state.startup_radio_task = startup_radio_task

View File

@@ -509,7 +509,7 @@ class RadioManager:
return False
except Exception as e:
logger.warning("Reconnection failed: %s", e)
logger.warning("Reconnection failed: %s", e, exc_info=True)
broadcast_error("Reconnection failed", str(e))
return False

View File

@@ -483,7 +483,7 @@ async def send_advertisement(mc: MeshCore, *, force: bool = False) -> bool:
logger.warning("Failed to send advertisement: %s", result.payload)
return False
except Exception as e:
logger.warning("Error sending advertisement: %s", e)
logger.warning("Error sending advertisement: %s", e, exc_info=True)
return False
@@ -514,7 +514,7 @@ async def _periodic_advert_loop():
logger.info("Periodic advertisement task cancelled")
break
except Exception as e:
logger.error("Error in periodic advertisement loop: %s", e)
logger.error("Error in periodic advertisement loop: %s", e, exc_info=True)
await asyncio.sleep(ADVERT_CHECK_INTERVAL)
@@ -554,7 +554,7 @@ async def sync_radio_time(mc: MeshCore) -> bool:
logger.debug("Synced radio time to %d", now)
return True
except Exception as e:
logger.warning("Failed to sync radio time: %s", e)
logger.warning("Failed to sync radio time: %s", e, exc_info=True)
return False
@@ -580,7 +580,7 @@ async def _periodic_sync_loop():
logger.info("Periodic sync task cancelled")
break
except Exception as e:
logger.error("Error in periodic sync: %s", e)
logger.error("Error in periodic sync: %s", e, exc_info=True)
def start_periodic_sync():
@@ -772,5 +772,5 @@ async def sync_recent_contacts_to_radio(force: bool = False, mc: MeshCore | None
return {"loaded": 0, "busy": True}
except Exception as e:
logger.error("Error syncing contacts to radio: %s", e)
logger.error("Error syncing contacts to radio: %s", e, exc_info=True)
return {"loaded": 0, "error": str(e)}