diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-24 00:23:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-24 00:25:23 +0100 |
commit | b6f49924bec74d93d52dae7b311938e37c68947e (patch) | |
tree | 6b55f53a1528fb57a442e6f97742ac4e691cb2e5 /Userland/Libraries/LibDesktop/Launcher.cpp | |
parent | 4a64bb80eaec84de46a12dac74c27cbf1a0b1bd8 (diff) | |
download | serenity-b6f49924bec74d93d52dae7b311938e37c68947e.zip |
LibDesktop: Make allowlist APIs return ErrorOr<void>
This makes it very smooth to use TRY() when setting up these lists,
as you can see in the rest of this commit. :^)
Diffstat (limited to 'Userland/Libraries/LibDesktop/Launcher.cpp')
-rw-r--r-- | Userland/Libraries/LibDesktop/Launcher.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index 36a2af332c..4af7c4c8de 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -50,44 +50,36 @@ static LaunchServerConnection& connection() return connection; } -bool Launcher::add_allowed_url(const URL& url) +ErrorOr<void> Launcher::add_allowed_url(URL const& url) { auto response_or_error = connection().try_add_allowed_url(url); - if (response_or_error.is_error()) { - dbgln("Launcher::add_allowed_url: Failed"); - return false; - } - return true; + if (response_or_error.is_error()) + return Error::from_string_literal("Launcher::add_allowed_url: Failed"sv); + return {}; } -bool Launcher::add_allowed_handler_with_any_url(const String& handler) +ErrorOr<void> Launcher::add_allowed_handler_with_any_url(String const& handler) { auto response_or_error = connection().try_add_allowed_handler_with_any_url(handler); - if (response_or_error.is_error()) { - dbgln("Launcher::add_allowed_handler_with_any_url: Failed"); - return false; - } - return true; + if (response_or_error.is_error()) + return Error::from_string_literal("Launcher::add_allowed_handler_with_any_url: Failed"sv); + return {}; } -bool Launcher::add_allowed_handler_with_only_specific_urls(const String& handler, const Vector<URL>& urls) +ErrorOr<void> Launcher::add_allowed_handler_with_only_specific_urls(String const& handler, Vector<URL> const& urls) { auto response_or_error = connection().try_add_allowed_handler_with_only_specific_urls(handler, urls); - if (response_or_error.is_error()) { - dbgln("Launcher::add_allowed_handler_with_only_specific_urls: Failed"); - return false; - } - return true; + if (response_or_error.is_error()) + return Error::from_string_literal("Launcher::add_allowed_handler_with_only_specific_urls: Failed"sv); + return {}; } -bool Launcher::seal_allowlist() +ErrorOr<void> Launcher::seal_allowlist() { auto response_or_error = connection().try_seal_allowlist(); - if (response_or_error.is_error()) { - dbgln("Launcher::seal_allowlist: Failed"); - return false; - } - return true; + if (response_or_error.is_error()) + return Error::from_string_literal("Launcher::seal_allowlist: Failed"sv); + return {}; } bool Launcher::open(const URL& url, const String& handler_name) |