use proper error handling

This commit is contained in:
2025-03-15 01:13:48 +01:00
parent 48b0777d94
commit b993f2b037
2 changed files with 39 additions and 16 deletions

View File

@@ -123,6 +123,12 @@ impl TankState {
}
}
pub fn got_error(&self, config: &TankConfig) -> Option<TankError> {
match self {
TankState::TankSensorPresent(raw_value_mv) => raw_voltage_to_tank_fill_percent(*raw_value_mv, config).err(),
TankState::TankSensorDisabled => Some(TankError::SensorDisabled),
}
}
}