diff options
author | Linus Groh <mail@linusgroh.de> | 2023-03-09 15:50:10 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-09 15:50:45 +0000 |
commit | ac9c39fa178d82d41256ea35b10284b4584f1f0a (patch) | |
tree | 572dfadd9041d3ab9b4bb35d728bbd2f7e02315f /Userland/Applications | |
parent | 077f7d1577ffb31fac9dd996e984dff9f76c8341 (diff) | |
download | serenity-ac9c39fa178d82d41256ea35b10284b4584f1f0a.zip |
CrashReporter: Handle backtrace OOM errors
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/CrashReporter/main.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index eceba09693..e08df1d82e 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * Copyright (c) 2022, Ali Chraghi <chraghiali1@gmail.com> * @@ -275,9 +275,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::show(window, DeprecatedString::formatted("Communication failed with FileSystemAccessServer: {}.", file_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); return; } - auto file = file_or_error.release_value().release_stream(); - if (auto result = file->write(full_backtrace.to_byte_buffer()); result.is_error()) + + auto byte_buffer_or_error = full_backtrace.try_to_byte_buffer(); + if (byte_buffer_or_error.is_error()) { + GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't create backtrace: {}.", byte_buffer_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); + return; + } + auto byte_buffer = byte_buffer_or_error.release_value(); + + if (auto result = file->write(byte_buffer); result.is_error()) GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't save file: {}.", result.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); }; save_backtrace_button.set_enabled(false); |