1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

LibCore+Everywhere: Return ErrorOr from ConfigFile factory methods

I've attempted to handle the errors gracefully where it was clear how to
do so, and simple, but a lot of this was just adding
`release_value_but_fixme_should_propagate_errors()` in places.
This commit is contained in:
Sam Atkins 2022-02-06 13:33:42 +00:00 committed by Tim Flynn
parent 1a4dd47d5f
commit 8260135d4d
31 changed files with 77 additions and 51 deletions

View file

@ -786,7 +786,7 @@ Messages::WindowServer::SetSystemThemeResponse ClientConnection::set_system_them
Messages::WindowServer::GetSystemThemeResponse ClientConnection::get_system_theme()
{
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini");
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini").release_value_but_fixme_should_propagate_errors();
auto name = wm_config->read_entry("Theme", "Name");
return name;
}
@ -798,7 +798,7 @@ void ClientConnection::apply_cursor_theme(String const& name)
Messages::WindowServer::GetCursorThemeResponse ClientConnection::get_cursor_theme()
{
auto config = Core::ConfigFile::open("/etc/WindowServer.ini");
auto config = Core::ConfigFile::open("/etc/WindowServer.ini").release_value_but_fixme_should_propagate_errors();
auto name = config->read_entry("Mouse", "CursorTheme");
return name;
}
@ -822,7 +822,12 @@ Messages::WindowServer::SetSystemFontsResponse ClientConnection::set_system_font
WindowManager::the().invalidate_after_theme_or_font_change();
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini", Core::ConfigFile::AllowWriting::Yes);
auto wm_config_or_error = Core::ConfigFile::open("/etc/WindowServer.ini", Core::ConfigFile::AllowWriting::Yes);
if (wm_config_or_error.is_error()) {
dbgln("Unable to open WindowServer.ini to set system fonts: {}", wm_config_or_error.error());
return false;
}
auto wm_config = wm_config_or_error.release_value();
wm_config->write_entry("Fonts", "Default", default_font_query);
wm_config->write_entry("Fonts", "FixedWidth", fixed_width_font_query);
return true;