1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

Applications: Improve FSAC error message handling

Fixes apps showing redundant error messages and terminating
unnecessarily on failed file requests. It's nicer to drop the
user off at the equivalent of a default document on failure if
possible.

Also fixes TextEditor not showing response errors for missing files
in the recently opened list.
This commit is contained in:
thankyouverycool 2023-05-18 08:50:38 -04:00 committed by Andreas Kling
parent fef594708e
commit 444470b238
5 changed files with 17 additions and 19 deletions

View file

@ -59,14 +59,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto default_path = TRY(String::from_deprecated_string(Config::read_string("FontEditor"sv, "Defaults"sv, "Font"sv, {})));
auto path_to_load = path.is_empty() ? default_path : path;
auto open_or_error = [&]() -> ErrorOr<void> {
if (path_to_load.is_empty())
return {};
auto file = TRY(FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path_to_load));
return TRY(font_editor->open_file(path, file.release_stream()));
}();
if (open_or_error.is_error())
font_editor->show_error(open_or_error.release_error(), "Opening"sv, path_to_load);
if (!path_to_load.is_empty()) {
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path_to_load);
if (!response.is_error()) {
if (auto result = font_editor->open_file(path, response.value().release_stream()); result.is_error())
font_editor->show_error(result.release_error(), "Opening"sv, path_to_load);
}
}
return app->exec();
}