Don't catch unhandled exceptions so Sentry can report them

If we catch all exceptions and { do nothing }, we are probably missing
some crashes from being reported.
This commit is contained in:
David Capello 2024-01-03 12:04:55 -03:00
parent 318a2c60ea
commit 88e89b6c38
3 changed files with 23 additions and 9 deletions

View File

@ -119,13 +119,19 @@ bool Sentry::areThereCrashesToReport()
return false;
}
// static
void Sentry::addBreadcrumb(const char* message)
{
LOG(VERBOSE, "BC: %s\n", message);
sentry_value_t c = sentry_value_new_breadcrumb(nullptr, message);
sentry_add_breadcrumb(c);
}
// static
void Sentry::addBreadcrumb(const std::string& message)
{
LOG(VERBOSE, "BC: %s\n", message.c_str());
sentry_value_t c = sentry_value_new_breadcrumb(nullptr, message.c_str());
sentry_add_breadcrumb(c);
addBreadcrumb(message.c_str());
}
// static

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021-2022 Igara Studio S.A.
// Copyright (C) 2021-2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -34,6 +34,7 @@ public:
// the "give consent" check box for first time.
static bool areThereCrashesToReport();
static void addBreadcrumb(const char* message);
static void addBreadcrumb(const std::string& message);
static void addBreadcrumb(const std::string& message,
const std::map<std::string, std::string>& data);

View File

@ -116,12 +116,12 @@ int app_main(int argc, char* argv[])
// Main thread name
base::this_thread::set_name("main");
try {
#if ENABLE_SENTRY
app::Sentry sentry;
app::Sentry sentry;
#else
base::MemoryDump memoryDump;
base::MemoryDump memoryDump;
#endif
try {
MemLeak memleak;
base::SystemConsole systemConsole;
app::AppOptions options(argc, const_cast<const char**>(argv));
@ -158,6 +158,13 @@ int app_main(int argc, char* argv[])
catch (std::exception& e) {
std::cerr << e.what() << '\n';
os::error_message(e.what());
return 1;
#if ENABLE_SENTRY
sentry.addBreadcrumb(e.what());
#endif
// Crash with the unhandled exception, so the OS or Sentry can
// handle/report the crash.
throw;
}
}