diff options
author | Karol Kosek <krkk@serenityos.org> | 2022-05-22 11:13:46 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-05-24 03:36:04 +0430 |
commit | 01824fd19a3c92475120e8782684be89257bf09d (patch) | |
tree | 1938047b054f64a22489dcee59e14012c783471d /Userland/Applications/Spreadsheet | |
parent | ca42da23c232623f28bb67bb6a373709701875fe (diff) | |
download | serenity-01824fd19a3c92475120e8782684be89257bf09d.zip |
Spreadsheet: Use TRY() on file load and save
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/Workbook.cpp | 10 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/main.cpp | 6 |
2 files changed, 4 insertions, 12 deletions
diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index 73d4e0fe87..5c784f95db 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -57,11 +57,7 @@ Result<bool, String> Workbook::open_file(Core::File& file) auto mime = Core::guess_mime_type_based_on_filename(file.filename()); // Make an import dialog, we might need to import it. - auto result = ImportDialog::make_and_run_for(m_parent_window, mime, file, *this); - if (result.is_error()) - return result.error(); - - m_sheets = result.release_value(); + m_sheets = TRY(ImportDialog::make_and_run_for(m_parent_window, mime, file, *this)); set_filename(file.filename()); @@ -99,9 +95,7 @@ Result<bool, String> Workbook::save(StringView filename) } // Make an export dialog, we might need to import it. - auto result = ExportDialog::make_and_run_for(mime, *file, *this); - if (result.is_error()) - return result.error(); + TRY(ExportDialog::make_and_run_for(mime, *file, *this)); set_filename(filename); set_dirty(false); diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 25e03aad3d..53408b712b 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -71,10 +71,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) window->show(); if (filename) { - auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, filename); - if (response.is_error()) - return 1; - spreadsheet_widget.load_file(*response.value()); + auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, filename)); + spreadsheet_widget.load_file(file); } return app->exec(); |