From dd12ad9477911de60a2ed1e811e079f749338002 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 6 Aug 2023 12:53:03 +0300 Subject: [PATCH] Add special handling for util::exception in various places to print stacktrace info --- libs/async/source/threadpool.cpp | 5 +++++ libs/sdl2/source/main.cpp | 6 ++++++ tools/test/source/main.cpp | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/libs/async/source/threadpool.cpp b/libs/async/source/threadpool.cpp index 2b1d5a2f..c5b5d417 100644 --- a/libs/async/source/threadpool.cpp +++ b/libs/async/source/threadpool.cpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -41,6 +42,10 @@ namespace psemek::async { running = false; } + catch (util::exception const & e) + { + log::error() << "Unhandled exception in threadpool executor: " << e; + } catch (std::exception const & e) { log::error() << "Unhandled exception in threadpool executor: " << e.what(); diff --git a/libs/sdl2/source/main.cpp b/libs/sdl2/source/main.cpp index 897c65b8..deea9985 100644 --- a/libs/sdl2/source/main.cpp +++ b/libs/sdl2/source/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #undef main @@ -62,6 +63,11 @@ int main(int argc, char ** argv) try log::info() << "Quitting"; return EXIT_SUCCESS; } +catch (psemek::util::exception const & e) +{ + psemek::log::error() << e; + return EXIT_FAILURE; +} catch (std::exception const & e) { psemek::log::error() << e.what(); diff --git a/tools/test/source/main.cpp b/tools/test/source/main.cpp index 5c11f1c8..daa74404 100644 --- a/tools/test/source/main.cpp +++ b/tools/test/source/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -176,6 +177,12 @@ int main(int argc, char ** argv) std::cout << indent << "Reason: " << yellow << e.message() << normal << std::endl; std::cout << indent << "Location: " << cyan << e.location() << normal << std::endl; } + catch (psemek::util::exception const & e) + { + auto end = clock::now(); + std::cout << red << "failure: " << e.what() << normal << " " << psemek::util::pretty(end - start, std::chrono::milliseconds{1}) << std::endl; + std::cout << red << e.stacktrace(); + } catch (std::exception const & e) { auto end = clock::now();