refactor: improve logging of send_webxdc_status_update errors

send_webxdc_status_update JSON-RPC call
and corresponding Rust call sometimes fail in CI with
---
database is locked

Caused by:
    Error code 5: The database file is locked
---

Adding more context to send_webxdc_status_update() errors
to better localize the error origin.
This commit is contained in:
link2xt
2023-11-28 17:56:44 +00:00
parent 4287a4d3ad
commit b9fa05c3bb

View File

@@ -462,13 +462,8 @@ impl Context {
update_str: &str, update_str: &str,
descr: &str, descr: &str,
) -> Result<()> { ) -> Result<()> {
let status_update_item: StatusUpdateItem = let status_update_item: StatusUpdateItem = serde_json::from_str(update_str)
if let Ok(item) = serde_json::from_str::<StatusUpdateItem>(update_str) { .with_context(|| format!("Failed to parse webxdc update item from {update_str:?}"))?;
item
} else {
bail!("create_status_update_record: no valid update item.");
};
self.send_webxdc_status_update_struct(instance_msg_id, status_update_item, descr) self.send_webxdc_status_update_struct(instance_msg_id, status_update_item, descr)
.await?; .await?;
Ok(()) Ok(())
@@ -515,7 +510,7 @@ impl Context {
ON CONFLICT(msg_id) ON CONFLICT(msg_id)
DO UPDATE SET last_serial=excluded.last_serial, descr=excluded.descr", DO UPDATE SET last_serial=excluded.last_serial, descr=excluded.descr",
(instance.id, status_update_serial, status_update_serial, descr), (instance.id, status_update_serial, status_update_serial, descr),
).await?; ).await.context("Failed to insert webxdc update into SMTP queue")?;
self.scheduler.interrupt_smtp().await; self.scheduler.interrupt_smtp().await;
} }
Ok(()) Ok(())