Replace expect usage with Result

This commit is contained in:
Tobias Reisinger 2023-12-05 01:42:19 +01:00
parent 9394a1ae52
commit b3228ea6b5
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
11 changed files with 135 additions and 95 deletions
emgauwa-controller/src

View file

@ -1,3 +1,4 @@
use emgauwa_lib::errors::EmgauwaError;
use emgauwa_lib::{constants, utils};
use serde_derive::Deserialize;
@ -83,8 +84,8 @@ impl Default for Logging {
}
}
pub fn init() -> Settings {
let mut settings: Settings = utils::load_settings("controller", "CONTROLLER");
pub fn init() -> Result<Settings, EmgauwaError> {
let mut settings: Settings = utils::load_settings("controller", "CONTROLLER")?;
for (num, relay) in settings.relays.iter_mut().enumerate() {
if relay.number.is_none() {
@ -92,5 +93,5 @@ pub fn init() -> Settings {
}
}
settings
Ok(settings)
}