mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-08-12 11:31:29 +00:00
tui: add better error handling to BootdiskOptions::get_values()
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
fccf6bb019
commit
994c4ff0a7
@ -352,18 +352,19 @@ fn bootdisk_dialog(siv: &mut Cursive) -> InstallerView {
|
|||||||
BootdiskOptionsView::new(&state.runtime_info.disks, &state.options.bootdisk)
|
BootdiskOptionsView::new(&state.runtime_info.disks, &state.options.bootdisk)
|
||||||
.with_name("bootdisk-options"),
|
.with_name("bootdisk-options"),
|
||||||
Box::new(|siv| {
|
Box::new(|siv| {
|
||||||
let options = siv
|
let options = siv.call_on_name("bootdisk-options", BootdiskOptionsView::get_values);
|
||||||
.call_on_name("bootdisk-options", BootdiskOptionsView::get_values)
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
if let Some(options) = options {
|
match options {
|
||||||
siv.with_user_data(|state: &mut InstallerState| {
|
Some(Ok(options)) => {
|
||||||
state.options.bootdisk = options;
|
siv.with_user_data(|state: &mut InstallerState| {
|
||||||
});
|
state.options.bootdisk = options;
|
||||||
|
});
|
||||||
|
|
||||||
switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
|
switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
|
||||||
} else {
|
}
|
||||||
siv.add_layer(Dialog::info("Invalid values"));
|
|
||||||
|
Some(Err(err)) => siv.add_layer(Dialog::info(format!("Invalid values: {err}"))),
|
||||||
|
_ => siv.add_layer(Dialog::info("Invalid values")),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -52,21 +52,22 @@ impl BootdiskOptionsView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_values(&mut self) -> Option<BootdiskOptions> {
|
pub fn get_values(&mut self) -> Result<BootdiskOptions, String> {
|
||||||
let mut options = (*self.advanced_options).clone().into_inner();
|
let mut options = (*self.advanced_options).clone().into_inner();
|
||||||
|
|
||||||
if [FsType::Ext4, FsType::Xfs].contains(&options.fstype) {
|
if [FsType::Ext4, FsType::Xfs].contains(&options.fstype) {
|
||||||
let disk = self
|
let disk = self
|
||||||
.view
|
.view
|
||||||
.get_child_mut(0)?
|
.get_child_mut(0)
|
||||||
.downcast_mut::<NamedView<FormView>>()?
|
.and_then(|v| v.downcast_mut::<NamedView<FormView>>())
|
||||||
.get_mut()
|
.map(NamedView::<FormView>::get_mut)
|
||||||
.get_value::<SelectView<Disk>, _>(0)?;
|
.and_then(|v| v.get_value::<SelectView<Disk>, _>(0))
|
||||||
|
.ok_or("failed to retrieve filesystem type")?;
|
||||||
|
|
||||||
options.disks = vec![disk];
|
options.disks = vec![disk];
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(options)
|
Ok(options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user