1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:38:13 +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

@ -76,19 +76,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!file_to_edit.is_empty()) {
auto filename = TRY(String::from_utf8(file_to_edit));
FileArgument parsed_argument(filename);
FileSystemAccessClient::Client::the().set_silence_errors(FileSystemAccessClient::ErrorFlag::NoEntries);
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, parsed_argument.filename().to_deprecated_string());
if (response.is_error()) {
if (response.error().code() == ENOENT)
text_widget->open_nonexistent_file(parsed_argument.filename().to_deprecated_string());
else
return 1;
} else {
TRY(text_widget->read_file(response.value().filename(), response.value().stream()));
text_widget->editor().set_cursor_and_focus_line(parsed_argument.line().value_or(1) - 1, parsed_argument.column().value_or(0));
}
text_widget->update_title();
FileSystemAccessClient::Client::the().set_silence_errors(FileSystemAccessClient::ErrorFlag::None);
}
text_widget->update_statusbar();