1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 01:35:08 +00:00

Profiler: Show a GUI message box with the error when profiling fails

This came up in @jonathandturner's video walking through the system
and playing with things: https://www.youtube.com/watch?v=TtV86uL5oD4

At one point, he tried profiling his Terminal app, and since the
Terminal was completely idle while profiling, no samples were captured
and there was no profile to show.

Make sure we propagate any error when loading the profile, and show it
in a GUI message box instead of stderr. :^)
This commit is contained in:
Andreas Kling 2020-12-26 10:27:57 +01:00
parent b2316701a8
commit bd47957c3a
3 changed files with 19 additions and 23 deletions

View file

@ -71,13 +71,14 @@ int main(int argc, char** argv)
path = argv[1];
}
auto profile = Profile::load_from_perfcore_file(path);
if (!profile) {
warnln("Unable to load profile '{}'", path);
return 1;
auto profile_or_error = Profile::load_from_perfcore_file(path);
if (profile_or_error.is_error()) {
GUI::MessageBox::show(nullptr, profile_or_error.error(), "Profiler", GUI::MessageBox::Type::Error);
return 0;
}
auto& profile = profile_or_error.value();
auto window = GUI::Window::construct();
window->set_title("Profiler");
window->set_icon(app_icon.bitmap_for_size(16));