mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
Userland: Propagate errors with TRY()
where possible
This commit is contained in:
parent
3ffa2a39bc
commit
2331d2bafa
6 changed files with 20 additions and 20 deletions
|
@ -26,7 +26,7 @@ ErrorOr<NonnullRefPtr<AddEventWidget>> AddEventWidget::create(AddEventDialog* wi
|
|||
|
||||
widget->m_start_date_box = *widget->find_descendant_of_type_named<GUI::TextBox>("start_date");
|
||||
|
||||
auto calendar_date_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
auto calendar_date_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png"sv));
|
||||
|
||||
auto& pick_start_date_button = *widget->find_descendant_of_type_named<GUI::Button>("pick_start_date");
|
||||
pick_start_date_button.set_icon(calendar_date_icon);
|
||||
|
|
|
@ -149,7 +149,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
m_editor->update();
|
||||
};
|
||||
|
||||
m_new_action = GUI::Action::create("New...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
m_new_action = GUI::Action::create("New...", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv)), [this](const GUI::Action&) {
|
||||
String value;
|
||||
if (request_close() && GUI::InputBox::show(window(), value, "Enter a size:"sv, "New File"sv, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) {
|
||||
auto file_size = AK::StringUtils::convert_to_uint(value);
|
||||
|
@ -208,7 +208,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
dbgln("Wrote document to {}", file.filename());
|
||||
});
|
||||
|
||||
m_open_annotations_action = GUI::Action::create("Load Annotations...", Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
m_open_annotations_action = GUI::Action::create("Load Annotations...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv)), [this](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(),
|
||||
{ .window_title = "Load annotations file"sv,
|
||||
.requested_access = Core::File::OpenMode::Read,
|
||||
|
@ -225,7 +225,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
});
|
||||
m_open_annotations_action->set_status_tip("Load annotations from a file"_string);
|
||||
|
||||
m_save_annotations_action = GUI::Action::create("Save Annotations", Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
m_save_annotations_action = GUI::Action::create("Save Annotations", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv)), [&](auto&) {
|
||||
if (m_annotations_path.is_empty())
|
||||
return m_save_annotations_as_action->activate();
|
||||
|
||||
|
@ -239,7 +239,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
});
|
||||
m_save_annotations_action->set_status_tip("Save annotations to a file"_string);
|
||||
|
||||
m_save_annotations_as_action = GUI::Action::create("Save Annotations As...", Gfx::Bitmap::load_from_file("/res/icons/16x16/save-as.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
m_save_annotations_as_action = GUI::Action::create("Save Annotations As...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/save-as.png"sv)), [&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, "annotations"sv, Core::File::OpenMode::Write | Core::File::OpenMode::Truncate);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
@ -260,7 +260,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
});
|
||||
m_redo_action->set_enabled(false);
|
||||
|
||||
m_find_action = GUI::Action::create("&Find...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
|
||||
m_find_action = GUI::Action::create("&Find...", { Mod_Ctrl, Key_F }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)), [&](const GUI::Action&) {
|
||||
auto old_buffer = m_search_buffer;
|
||||
bool find_all = false;
|
||||
if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecResult::OK) {
|
||||
|
@ -297,7 +297,7 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
}
|
||||
});
|
||||
|
||||
m_goto_offset_action = GUI::Action::create("&Go to Offset...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
m_goto_offset_action = GUI::Action::create("&Go to Offset...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"sv)), [this](const GUI::Action&) {
|
||||
int new_offset;
|
||||
auto result = GoToOffsetDialog::show(
|
||||
window(),
|
||||
|
@ -326,17 +326,17 @@ ErrorOr<void> HexEditorWidget::setup()
|
|||
Config::write_bool("HexEditor"sv, "Layout"sv, "ShowSearchResults"sv, action.is_checked());
|
||||
});
|
||||
|
||||
m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/hex.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
|
||||
m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/hex.png"sv)), [&](const GUI::Action&) {
|
||||
m_editor->copy_selected_hex_to_clipboard();
|
||||
});
|
||||
m_copy_hex_action->set_enabled(false);
|
||||
|
||||
m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
|
||||
m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv)), [&](const GUI::Action&) {
|
||||
m_editor->copy_selected_text_to_clipboard();
|
||||
});
|
||||
m_copy_text_action->set_enabled(false);
|
||||
|
||||
m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/c.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
|
||||
m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/c.png"sv)), [&](const GUI::Action&) {
|
||||
m_editor->copy_selected_hex_to_clipboard_as_c_code();
|
||||
});
|
||||
m_copy_as_c_code_action->set_enabled(false);
|
||||
|
@ -563,7 +563,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
|||
edit_menu->add_separator();
|
||||
edit_menu->add_action(GUI::Action::create(
|
||||
"Add Annotation",
|
||||
Gfx::Bitmap::load_from_file("/res/icons/16x16/annotation-add.png"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/annotation-add.png"sv)),
|
||||
[this](GUI::Action&) { m_editor->show_create_annotation_dialog(); },
|
||||
this));
|
||||
edit_menu->add_separator();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
namespace TerminalSettings {
|
||||
ErrorOr<NonnullRefPtr<MainWidget>> MainWidget::create()
|
||||
{
|
||||
auto widget = MainWidget::try_create().release_value_but_fixme_should_propagate_errors();
|
||||
auto widget = TRY(MainWidget::try_create());
|
||||
TRY(widget->setup());
|
||||
return widget;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ ErrorOr<void> GalleryWidget::load_basic_model_tab()
|
|||
m_add_new_item = *tab.find_descendant_of_type_named<GUI::Button>("add_new_item");
|
||||
m_remove_selected_item = *tab.find_descendant_of_type_named<GUI::Button>("remove_selected_item");
|
||||
|
||||
m_add_new_item->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
m_remove_selected_item->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
m_add_new_item->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv)));
|
||||
m_remove_selected_item->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png"sv)));
|
||||
|
||||
m_new_item_name->on_return_pressed = [&] { add_textbox_contents_to_basic_model(); };
|
||||
m_add_new_item->on_click = [&](auto) { add_textbox_contents_to_basic_model(); };
|
||||
|
|
|
@ -172,12 +172,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
update_source_model();
|
||||
};
|
||||
|
||||
auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
|
||||
auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/x86.png"sv)), [&](auto& action) {
|
||||
disassembly_view.set_visible(action.is_checked());
|
||||
update_disassembly_model();
|
||||
});
|
||||
|
||||
auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
|
||||
auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/x86.png"sv)), [&](auto& action) {
|
||||
source_view.set_visible(action.is_checked());
|
||||
update_source_model();
|
||||
});
|
||||
|
|
|
@ -37,14 +37,14 @@ struct Proxy {
|
|||
ErrorOr<NonnullOwnPtr<StorageType>> tunnel(URL const& url, Args&&... args)
|
||||
{
|
||||
if (data.type == Core::ProxyData::Direct) {
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default(), forward<Args>(args)...));
|
||||
return TRY(SocketType::connect(TRY(url.serialized_host()).to_byte_string(), url.port_or_default(), forward<Args>(args)...));
|
||||
}
|
||||
if (data.type == Core::ProxyData::SOCKS5) {
|
||||
if constexpr (requires { SocketType::connect(declval<ByteString>(), *proxy_client_storage, forward<Args>(args)...); }) {
|
||||
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), *proxy_client_storage, forward<Args>(args)...));
|
||||
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, TRY(url.serialized_host()).to_byte_string(), url.port_or_default()));
|
||||
return TRY(SocketType::connect(TRY(url.serialized_host()).to_byte_string(), *proxy_client_storage, forward<Args>(args)...));
|
||||
} else if constexpr (IsSame<SocketType, Core::TCPSocket>) {
|
||||
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
|
||||
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, TRY(url.serialized_host()).to_byte_string(), url.port_or_default()));
|
||||
} else {
|
||||
return Error::from_string_literal("SOCKS5 not supported for this socket type");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue