diff --git a/src/app/sentry_wrapper.cpp b/src/app/sentry_wrapper.cpp index d2ba23e80..1916b1ca8 100644 --- a/src/app/sentry_wrapper.cpp +++ b/src/app/sentry_wrapper.cpp @@ -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 diff --git a/src/app/sentry_wrapper.h b/src/app/sentry_wrapper.h index e9ac6da78..ff6b2c3d9 100644 --- a/src/app/sentry_wrapper.h +++ b/src/app/sentry_wrapper.h @@ -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& data); diff --git a/src/main/main.cpp b/src/main/main.cpp index 4778435fc..aeb54010d 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -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(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; } }