diff options
Diffstat (limited to 'Userland')
21 files changed, 56 insertions, 64 deletions
diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 1f4930ec9b..a3dc9d71a7 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -101,9 +101,9 @@ ErrorOr<void> MainWidget::create_actions() new_font_wizard->hide(); auto maybe_font = new_font_wizard->create_font(); if (maybe_font.is_error()) - return show_error(maybe_font.error(), "Creating new font failed"sv); + return show_error(maybe_font.release_error(), "Creating new font failed"sv); if (auto result = initialize({}, move(maybe_font.value())); result.is_error()) - show_error(result.error(), "Initializing new font failed"sv); + show_error(result.release_error(), "Initializing new font failed"sv); }); m_new_action->set_status_tip("Create a new font"); @@ -114,14 +114,14 @@ ErrorOr<void> MainWidget::create_actions() if (!open_path.has_value()) return; if (auto result = open_file(open_path.value()); result.is_error()) - show_error(result.error(), "Opening"sv, LexicalPath { open_path.value() }.basename()); + show_error(result.release_error(), "Opening"sv, LexicalPath { open_path.value() }.basename()); }); m_save_action = GUI::CommonActions::make_save_action([&](auto&) { if (m_path.is_empty()) return m_save_as_action->activate(); if (auto result = save_file(m_path); result.is_error()) - show_error(result.error(), "Saving"sv, LexicalPath { m_path }.basename()); + show_error(result.release_error(), "Saving"sv, LexicalPath { m_path }.basename()); }); m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { @@ -130,17 +130,17 @@ ErrorOr<void> MainWidget::create_actions() if (!save_path.has_value()) return; if (auto result = save_file(save_path.value()); result.is_error()) - show_error(result.error(), "Saving"sv, lexical_path.basename()); + show_error(result.release_error(), "Saving"sv, lexical_path.basename()); }); m_cut_action = GUI::CommonActions::make_cut_action([&](auto&) { if (auto result = cut_selected_glyphs(); result.is_error()) - show_error(result.error(), "Cutting selection failed"sv); + show_error(result.release_error(), "Cutting selection failed"sv); }); m_copy_action = GUI::CommonActions::make_copy_action([&](auto&) { if (auto result = copy_selected_glyphs(); result.is_error()) - show_error(result.error(), "Copying selection failed"sv); + show_error(result.release_error(), "Copying selection failed"sv); }); m_paste_action = GUI::CommonActions::make_paste_action([&](auto&) { @@ -178,7 +178,7 @@ ErrorOr<void> MainWidget::create_actions() m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) { if (!m_font_preview_window) { if (auto maybe_window = create_preview_window(); maybe_window.is_error()) - show_error(maybe_window.error(), "Creating preview window failed"sv); + show_error(maybe_window.release_error(), "Creating preview window failed"sv); else m_font_preview_window = maybe_window.release_value(); } @@ -792,12 +792,12 @@ void MainWidget::push_undo() { auto maybe_state = m_undo_selection->save_state(); if (maybe_state.is_error()) - return show_error(maybe_state.error(), "Saving undo state failed"sv); + return show_error(maybe_state.release_error(), "Saving undo state failed"sv); auto maybe_command = try_make<SelectionUndoCommand>(*m_undo_selection, move(maybe_state.value())); if (maybe_command.is_error()) - return show_error(maybe_command.error(), "Making undo command failed"sv); + return show_error(maybe_command.release_error(), "Making undo command failed"sv); if (auto maybe_push = m_undo_stack->try_push(move(maybe_command.value())); maybe_push.is_error()) - show_error(maybe_push.error(), "Pushing undo stack failed"sv); + show_error(maybe_push.release_error(), "Pushing undo stack failed"sv); } void MainWidget::reset_selection_and_push_undo() @@ -976,7 +976,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) return; if (auto result = open_file(urls.first().path()); result.is_error()) - show_error(result.error(), "Opening"sv, LexicalPath { urls.first().path() }.basename()); + show_error(result.release_error(), "Opening"sv, LexicalPath { urls.first().path() }.basename()); } } diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 099d3179d7..9d97082a3b 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -27,9 +27,8 @@ bool KeyboardMapperWidget::request_close() return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_filename); if (result == GUI::MessageBox::ExecResult::Yes) { - ErrorOr<void> error_or = save(); - if (error_or.is_error()) - show_error_to_user(error_or.error()); + if (auto error_or = save(); error_or.is_error()) + show_error_to_user(error_or.release_error()); if (!window()->is_modified()) return true; diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index 77ef321792..015e0270a2 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -54,16 +54,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!path.has_value()) return; - ErrorOr<void> error_or = keyboard_mapper_widget->load_map_from_file(path.value()); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->load_map_from_file(path.value()); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto save_action = GUI::CommonActions::make_save_action( [&](auto&) { - ErrorOr<void> error_or = keyboard_mapper_widget->save(); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->save(); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { @@ -72,9 +70,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!save_path.has_value()) return; - ErrorOr<void> error_or = keyboard_mapper_widget->save_to_file(save_path.value()); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->save_to_file(save_path.value()); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto quit_action = GUI::CommonActions::make_quit_action( diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 0132cc71d2..7cfd771a4c 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1021,8 +1021,8 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_debug_action() return; } - Debugger::the().set_child_setup_callback([this, ptm_res]() { - return m_terminal_wrapper->setup_slave_pseudoterminal(ptm_res.value()); + Debugger::the().set_child_setup_callback([this, ptm_res = ptm_res.release_value()]() { + return m_terminal_wrapper->setup_slave_pseudoterminal(ptm_res); }); m_debugger_thread = Threading::Thread::construct(Debugger::start_static); @@ -1789,7 +1789,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config auto maybe_error = Core::System::mkdir(LexicalPath::absolute_path(m_project->root_path(), parent_directory), 0755); if (maybe_error.is_error() && maybe_error.error().code() != EEXIST) - return maybe_error.error(); + return maybe_error.release_error(); auto file = TRY(Core::Stream::File::open(absolute_config_file_path, Core::Stream::OpenMode::Write)); TRY(file->write_entire_buffer( diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index e0f3d73423..f26f0a0722 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -47,7 +47,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file // the same as if we had opened an empty file. This behavior is a little weird, but is required by // user code, which does not check the config file exists before opening. if (!(allow_altering == AllowWriting::No && maybe_file.error().code() == ENOENT)) - return maybe_file.error(); + return maybe_file.release_error(); } else { buffered_file = TRY(Stream::BufferedFile::create(maybe_file.release_value())); } diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 5cf699c625..77a649fc33 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -531,7 +531,7 @@ ErrorOr<void, File::CopyError> File::copy_directory(DeprecatedString const& dst_ DeprecatedString::formatted("{}/{}", src_path, filename), RecursionMode::Allowed, link, AddDuplicateFileMarker::Yes, preserve_mode); if (result.is_error()) - return result.error(); + return result.release_error(); } auto my_umask = umask(0); diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index e899c34237..634a91ff0f 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -71,13 +71,13 @@ public: auto tag_or_error = peek(); if (tag_or_error.is_error()) { m_stack = move(previous_position); - return tag_or_error.error(); + return tag_or_error.release_error(); } auto length_or_error = read_length(); if (length_or_error.is_error()) { m_stack = move(previous_position); - return length_or_error.error(); + return length_or_error.release_error(); } auto length = length_or_error.value(); @@ -85,7 +85,7 @@ public: auto bytes_result = read_bytes(length); if (bytes_result.is_error()) { m_stack = move(previous_position); - return bytes_result.error(); + return bytes_result.release_error(); } m_current_tag.clear(); @@ -106,13 +106,13 @@ public: auto tag_or_error = peek(); if (tag_or_error.is_error()) { m_stack = move(previous_position); - return tag_or_error.error(); + return tag_or_error.release_error(); } auto length_or_error = read_length(); if (length_or_error.is_error()) { m_stack = move(previous_position); - return length_or_error.error(); + return length_or_error.release_error(); } auto tag = tag_or_error.value(); @@ -121,7 +121,7 @@ public: auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length); if (value_or_error.is_error()) { m_stack = move(previous_position); - return value_or_error.error(); + return value_or_error.release_error(); } m_current_tag.clear(); @@ -146,7 +146,7 @@ private: ErrorOr<ValueType> with_type_check(ErrorOr<DecodedType>&& value_or_error) { if (value_or_error.is_error()) - return value_or_error.error(); + return value_or_error.release_error(); if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) { return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type"); @@ -162,10 +162,7 @@ private: template<typename ValueType> ErrorOr<ValueType> read_value(Class klass, Kind kind, size_t length) { - auto data_or_error = read_bytes(length); - if (data_or_error.is_error()) - return data_or_error.error(); - auto data = data_or_error.value(); + auto data = TRY(read_bytes(length)); if (klass != Class::Universal) return with_type_check<ValueType>(data); diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp index 566f828915..f89d82aea8 100644 --- a/Userland/Libraries/LibEDID/EDID.cpp +++ b/Userland/Libraries/LibEDID/EDID.cpp @@ -907,14 +907,14 @@ ErrorOr<IterationDecision> Parser::for_each_detailed_timing(Function<IterationDe }); if (result.is_error()) { dbgln("Failed to iterate DTDs in CEA861 extension block: {}", result.error()); - extension_error = result.error(); + extension_error = result.release_error(); return IterationDecision::Break; } return result.value(); })); if (extension_error.has_value()) - return extension_error.value(); + return extension_error.release_value(); return result; } @@ -948,7 +948,7 @@ ErrorOr<IterationDecision> Parser::for_each_short_video_descriptor(Function<Iter return callback(block_id, is_native, vic); }); if (result.is_error()) { - extension_error = result.error(); + extension_error = result.release_error(); return IterationDecision::Break; } return result.value(); @@ -985,14 +985,14 @@ ErrorOr<IterationDecision> Parser::for_each_display_descriptor(Function<Iteratio }); if (result.is_error()) { dbgln("Failed to iterate display descriptors in CEA861 extension block: {}", result.error()); - extension_error = result.error(); + extension_error = result.release_error(); return IterationDecision::Break; } return result.value(); })); if (extension_error.has_value()) - return extension_error.value(); + return extension_error.release_value(); return result; } diff --git a/Userland/Libraries/LibGL/Shaders/Program.cpp b/Userland/Libraries/LibGL/Shaders/Program.cpp index 2fbd8ee772..533a8ccfca 100644 --- a/Userland/Libraries/LibGL/Shaders/Program.cpp +++ b/Userland/Libraries/LibGL/Shaders/Program.cpp @@ -65,7 +65,7 @@ ErrorOr<void> Program::link(GPU::Device& device) if (linked_vertex_shader_or_error.is_error()) { m_link_status = false; m_info_log = linker.messages(); - return linked_vertex_shader_or_error.error(); + return linked_vertex_shader_or_error.release_error(); } m_linked_vertex_shader = linked_vertex_shader_or_error.release_value(); @@ -81,7 +81,7 @@ ErrorOr<void> Program::link(GPU::Device& device) if (linked_fragment_shader_or_error.is_error()) { m_link_status = false; m_info_log = linker.messages(); - return linked_fragment_shader_or_error.error(); + return linked_fragment_shader_or_error.release_error(); } m_linked_fragment_shader = linked_fragment_shader_or_error.release_value(); diff --git a/Userland/Libraries/LibGL/Shaders/Shader.cpp b/Userland/Libraries/LibGL/Shaders/Shader.cpp index ebc77d86f3..7e2a1a82cb 100644 --- a/Userland/Libraries/LibGL/Shaders/Shader.cpp +++ b/Userland/Libraries/LibGL/Shaders/Shader.cpp @@ -33,7 +33,7 @@ ErrorOr<void> Shader::compile() if (object_file_or_error.is_error()) { m_compile_status = false; m_info_log = compiler.messages(); - return object_file_or_error.error(); + return object_file_or_error.release_error(); } m_object_file = object_file_or_error.release_value(); diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp index ff75f84f5f..6ad28a51d0 100644 --- a/Userland/Libraries/LibSQL/Heap.cpp +++ b/Userland/Libraries/LibSQL/Heap.cpp @@ -53,7 +53,7 @@ ErrorOr<void> Heap::open() if (file_size > 0) { if (auto error_maybe = read_zero_block(); error_maybe.is_error()) { m_file = nullptr; - return error_maybe.error(); + return error_maybe.release_error(); } } else { initialize_zero_block(); diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 296c78bfe6..b3953a01a0 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -85,7 +85,7 @@ void PlaybackManager::dispatch_fatal_error(Error error) // FIXME: For threading, this will have to use a pre-allocated event to send to the main loop // to be able to gracefully handle OOM. VERIFY(&m_main_loop == &Core::EventLoop::current()); - FatalPlaybackErrorEvent event { error }; + FatalPlaybackErrorEvent event { move(error) }; m_event_handler.dispatch_event(event); } diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h index 39c42c09b1..99909f7c12 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.h +++ b/Userland/Libraries/LibVideo/PlaybackManager.h @@ -247,11 +247,11 @@ class FatalPlaybackErrorEvent : public Core::Event { public: explicit FatalPlaybackErrorEvent(Error error) : Core::Event(FatalPlaybackError) - , m_error(error) + , m_error(move(error)) { } virtual ~FatalPlaybackErrorEvent() = default; - Error error() { return m_error; } + Error const& error() { return m_error; } private: Error m_error; diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index acba0370fb..7b50a85ea9 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -172,7 +172,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has dbgln("ResourceLoader: Finished load of: \"{}\", Duration: {}ms", url_for_logging, load_time_ms); }; - auto const log_failure = [url_for_logging, id](auto const& request, auto const error_message) { + auto const log_failure = [url_for_logging, id](auto const& request, auto const& error_message) { auto load_time_ms = request.load_time().to_milliseconds(); emit_signpost(DeprecatedString::formatted("Failed load: {}", url_for_logging), id); dbgln("ResourceLoader: Failed load of: \"{}\", \033[31;1mError: {}\033[0m, Duration: {}ms", url_for_logging, error_message, load_time_ms); diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp index 2e6b7f7c66..37e11d0ffd 100644 --- a/Userland/Services/FileOperation/main.cpp +++ b/Userland/Services/FileOperation/main.cpp @@ -243,7 +243,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items) if (auto result = destination_file->write(bytes_read); result.is_error()) { // FIXME: Return the formatted string directly. There is no way to do this right now without the temporary going out of scope and being destroyed. report_warning(DeprecatedString::formatted("Failed to write to destination file: {}", result.error())); - return result.error(); + return result.release_error(); } item_done += bytes_read.size(); executed_work_bytes += bytes_read.size(); diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index fb0e2df08b..de0783c099 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -238,8 +238,8 @@ public: void request_file(Web::FileRequest request) override { - auto const file = Core::System::open(request.path(), O_RDONLY); - request.on_file_request_finish(file); + auto file = Core::System::open(request.path(), O_RDONLY); + request.on_file_request_finish(move(file)); } private: diff --git a/Userland/Utilities/keymap.cpp b/Userland/Utilities/keymap.cpp index 25629ad1a7..3b03cd7ede 100644 --- a/Userland/Utilities/keymap.cpp +++ b/Userland/Utilities/keymap.cpp @@ -65,10 +65,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) // Verify that all specified keymaps are loadable for (auto& keymap_name : mappings_vector) { - auto keymap = Keyboard::CharacterMap::load_from_file(keymap_name); - if (keymap.is_error()) { + if (auto keymap = Keyboard::CharacterMap::load_from_file(keymap_name); keymap.is_error()) { warnln("Cannot load keymap {}: {}({})", keymap_name, keymap.error().string_literal(), keymap.error().code()); - return keymap.error(); + return keymap.release_error(); } } diff --git a/Userland/Utilities/ln.cpp b/Userland/Utilities/ln.cpp index a113857974..8d84257297 100644 --- a/Userland/Utilities/ln.cpp +++ b/Userland/Utilities/ln.cpp @@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto stat = Core::System::lstat(path); if (stat.is_error() && stat.error().code() != ENOENT) - return stat.error(); + return stat.release_error(); if (!stat.is_error() && S_ISDIR(stat.value().st_mode)) { // The target path is a directory, so we presumably want <path>/<filename> as the effective path. diff --git a/Userland/Utilities/rm.cpp b/Userland/Utilities/rm.cpp index 01f7b2be85..15670ec53d 100644 --- a/Userland/Utilities/rm.cpp +++ b/Userland/Utilities/rm.cpp @@ -46,7 +46,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto result = Core::File::remove(path, recursive ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed); if (result.is_error()) { - auto error = result.error(); + auto error = result.release_error(); if (force && error.is_errno() && error.code() == ENOENT) continue; diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index c4a7f1e34b..96b5fe0234 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -110,7 +110,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (event.type == Core::FileWatcherEvent::Type::ContentModified) { auto buffer_or_error = f->read_until_eof(); if (buffer_or_error.is_error()) { - auto error = buffer_or_error.error(); + auto error = buffer_or_error.release_error(); warnln(error.string_literal()); event_loop.quit(error.code()); return; @@ -120,7 +120,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto potential_error = f->seek(0, SeekMode::FromEndPosition); if (potential_error.is_error()) { - auto error = potential_error.error(); + auto error = potential_error.release_error(); warnln(error.string_literal()); event_loop.quit(error.code()); return; diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index eb4e804552..75fa1ff0fe 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -181,7 +181,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto result_or_error = Core::System::mkdir(absolute_path, header_mode); if (result_or_error.is_error() && result_or_error.error().code() != EEXIST) - return result_or_error.error(); + return result_or_error.release_error(); break; } default: |