From 0e62abfa1fa03ac7125643012b660d18ed05e35e Mon Sep 17 00:00:00 2001
From: Volkor <me@volkor.me>
Date: Mon, 10 Mar 2025 05:49:13 +1100
Subject: [PATCH] add some better logging to db

---
 src/gui/widgets/node_list.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gui/widgets/node_list.rs b/src/gui/widgets/node_list.rs
index ef02031..f204ea3 100644
--- a/src/gui/widgets/node_list.rs
+++ b/src/gui/widgets/node_list.rs
@@ -1,6 +1,8 @@
 use chrono::DateTime;
 use chrono_humanize::HumanTime;
 use egui_extras::{Column, TableBuilder};
+use figment::providers::Data;
+use log::{error, info};
 use longitude::{DistanceUnit, Location};
 use meshtastic::protobufs::{channel::Role, HardwareModel, Position};
 
@@ -45,7 +47,15 @@ pub(crate) fn calc_distance_to_node(away: Position) -> Option<f64> {
 /// UI Elements for the Node List
 pub fn nodelist_ui(ui: &mut egui::Ui) {
     // Get nodes from DB
-    let mut nodes = Database::read_node_list().expect("Failed to read nodes");
+    let mut nodes = Database::read_node_list().unwrap_or_else(|e| {
+        error!("Failed to read nodes: {}", e);
+        // Return a default value or handle the error as needed
+        Vec::new() // Example default value, replace with appropriate handling
+    });
+
+    info!("Loaded {} nodes from DB", nodes.len());
+
+    // let mut nodes = Database::read_node_list().expect("Failed to read nodes");
     
     // Sort nodes by `last_heard` in descending order
     nodes.sort_by(|a, b| b.last_heard.cmp(&a.last_heard));
-- 
GitLab