Display errors when loading ShapedDevices

This commit is contained in:
Herbert Wolverson
2023-01-19 20:16:20 +00:00
parent 3e12e95f66
commit 7a0f066c63
3 changed files with 7 additions and 0 deletions

1
src/rust/Cargo.lock generated
View File

@@ -1294,6 +1294,7 @@ dependencies = [
"csv",
"ip_network",
"ip_network_table",
"log",
"serde",
"sha2",
"toml",

View File

@@ -12,3 +12,4 @@ ip_network_table = "0"
ip_network = "0"
sha2 = "0"
uuid = { version = "1", features = ["v4", "fast-rng" ] }
log = "0"

View File

@@ -35,12 +35,17 @@ impl ConfigShapedDevices {
let mut reader = csv::Reader::from_path(final_path)?;
// Example: StringRecord(["1", "968 Circle St., Gurnee, IL 60031", "1", "Device 1", "", "", "192.168.101.2", "", "25", "5", "10000", "10000", ""])
let mut devices = Vec::new();
for result in reader.records() {
if let Ok(result) = result {
if let Ok(device) = ShapedDevice::from_csv(&result) {
devices.push(device);
} else {
log::error!("Error reading Device line: {:?}", &result);
}
} else {
log::error!("Error reading CSV record: {:?}", result);
}
}
let trie = ConfigShapedDevices::make_trie(&devices);