From c566ef2a9d49ad1c52945873154651cbdef0b908 Mon Sep 17 00:00:00 2001 From: Hugh Davenport Date: Sat, 6 Jan 2024 08:48:17 +1300 Subject: [PATCH] PartitionEditor: Show better error when can't find partition table --- Userland/Applications/PartitionEditor/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/PartitionEditor/main.cpp b/Userland/Applications/PartitionEditor/main.cpp index 80f6cb9a929..c39fffd0e0b 100644 --- a/Userland/Applications/PartitionEditor/main.cpp +++ b/Userland/Applications/PartitionEditor/main.cpp @@ -64,7 +64,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto device_paths = get_device_paths(); auto partition_model = PartitionEditor::PartitionModel::create(); - TRY(partition_model->set_device_path(device_paths.first())); + auto found_it = device_paths.find_if([&](auto const& path) { + auto result = partition_model->set_device_path(path); + return !result.is_error(); + }); + // FIXME: Give the user some way to create a partition table + if (found_it == device_paths.end()) + GUI::MessageBox::show_error(window, ByteString::formatted("No partition table found on any valid block device")); auto& device_combobox = *widget->find_descendant_of_type_named("device_combobox"); device_combobox.set_model(GUI::ItemListModel::create(device_paths));