From e2962222b7dd324f00c341384767096fbb5cb030 Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Sat, 21 Feb 2026 23:06:32 +0700 Subject: [PATCH] fix: Improve error handling for reflector list loading Improves error handling when the reflector list file is not found, providing more context about the failure. --- src/config.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 5eed159..6aefe85 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,7 @@ use anyhow::Result; +use log::Level; #[cfg(feature = "uci")] use log::warn; -use log::Level; #[cfg(feature = "uci")] use rust_uci::Uci; use std::fs::File; @@ -21,6 +21,8 @@ pub enum ConfigError { ParseError(String), #[error("No config value found for key: `{0}`")] MissingValue(String), + #[error("Reflector list not found at: {0}")] + ReflectorListNotFound(String), } fn read_lines

(filename: P) -> io::Result>> @@ -243,7 +245,11 @@ impl Config { } pub fn load_reflectors(&self) -> Result> { - let lines = read_lines(self.reflector_list_file.clone())?; + let lines = read_lines(self.reflector_list_file.clone()).map_err(|e| { + ConfigError::ReflectorListNotFound( + self.reflector_list_file.clone() + ": " + e.to_string().as_str(), + ) + })?; let mut reflectors: Vec = Vec::with_capacity(50);