From b9fa05c3bb8b87650bf7a274ed0b8adb70dc272c Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 28 Nov 2023 17:56:44 +0000 Subject: [PATCH] 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. --- src/webxdc.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/webxdc.rs b/src/webxdc.rs index f9b35d83aa..6d5467208d 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -462,13 +462,8 @@ impl Context { update_str: &str, descr: &str, ) -> Result<()> { - let status_update_item: StatusUpdateItem = - if let Ok(item) = serde_json::from_str::(update_str) { - item - } else { - bail!("create_status_update_record: no valid update item."); - }; - + let status_update_item: StatusUpdateItem = serde_json::from_str(update_str) + .with_context(|| format!("Failed to parse webxdc update item from {update_str:?}"))?; self.send_webxdc_status_update_struct(instance_msg_id, status_update_item, descr) .await?; Ok(()) @@ -515,7 +510,7 @@ impl Context { ON CONFLICT(msg_id) DO UPDATE SET last_serial=excluded.last_serial, descr=excluded.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; } Ok(())