Replace expect usage with Result
This commit is contained in:
parent
9394a1ae52
commit
b3228ea6b5
11 changed files with 135 additions and 95 deletions
emgauwa-controller/src
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue