more error handling

This commit is contained in:
galister
2024-02-19 01:05:50 +01:00
parent 63b43c0e59
commit 1d9fa95ea0
10 changed files with 125 additions and 116 deletions

View File

@@ -338,6 +338,7 @@ fn btn_func_dn(
func_right,
func_middle,
} = control.state.as_ref().unwrap()
// want to panic if state not found
else {
log::error!("FuncButton state not found");
return;
@@ -399,6 +400,7 @@ fn battery_update(control: &mut Control<(), ElemState>, _: &mut (), app: &mut Ap
fg_color_low,
fg_color_charging,
} = control.state.as_ref().unwrap()
// want to panic if state not found
else {
return;
};
@@ -444,6 +446,7 @@ fn exec_button(
ref mut child,
..
} = control.state.as_mut().unwrap()
// want to panic if state not found
else {
log::error!("ExecButton state not found");
return;
@@ -484,6 +487,7 @@ fn exec_label_update(control: &mut Control<(), ElemState>, _: &mut (), _: &mut A
exec,
ref mut child,
} = control.state.as_mut().unwrap()
// want to panic if state not found
else {
log::error!("AutoExec state not found");
return;
@@ -504,10 +508,9 @@ fn exec_label_update(control: &mut Control<(), ElemState>, _: &mut (), _: &mut A
return;
}
return;
} else {
log::error!("No stdout for child process");
return;
}
log::error!("No stdout for child process");
return;
}
}
Ok(None) => {
@@ -547,6 +550,7 @@ fn exec_label_update(control: &mut Control<(), ElemState>, _: &mut (), _: &mut A
}
fn clock_update(control: &mut Control<(), ElemState>, _: &mut (), _: &mut AppState) {
// want to panic if state not found
let ElemState::Clock { timezone, format } = control.state.as_ref().unwrap() else {
log::error!("Clock state not found");
return;
@@ -567,6 +571,7 @@ fn overlay_button_scroll(
app: &mut AppState,
delta: f32,
) {
// want to panic if state not found
let ElemState::OverlayButton { overlay, .. } = control.state.as_mut().unwrap() else {
log::error!("OverlayButton state not found");
return;
@@ -604,6 +609,7 @@ fn overlay_button_dn(
ref mut mode,
..
} = control.state.as_mut().unwrap()
// want to panic if state not found
else {
log::error!("OverlayButton state not found");
return;
@@ -618,6 +624,7 @@ fn overlay_button_up(control: &mut Control<(), ElemState>, _: &mut (), app: &mut
mode,
overlay,
} = control.state.as_ref().unwrap()
// want to panic if state not found
else {
log::error!("OverlayButton state not found");
return;