From 9c8bb278a26c0c4356d6ee5e66d3f34c70521fb8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 20 Feb 2021 01:15:52 +0200 Subject: [PATCH] Nicer formatting of exceptions with multi-line whats --- source/core/application.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/core/application.cpp b/source/core/application.cpp index aedaa4b..290f20b 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "application.h" #include "getopt.h" @@ -73,7 +74,15 @@ int Application::run(int argc, char **argv, void *data, void (*created_callback) { IO::print(IO::cerr, "An uncaught exception occurred.\n"); IO::print(IO::cerr, " type: %s\n", Debug::demangle(typeid(e).name())); - IO::print(IO::cerr, " what(): %s\n", e.what()); + vector lines = split(e.what(), '\n'); + if(lines.size()<2) + IO::print(IO::cerr, " what(): %s\n", e.what()); + else + { + IO::print(IO::cerr, " what(): %s\n", lines.front()); + for(vector::const_iterator i=lines.begin(); ++i!=lines.end(); ) + IO::print(IO::cerr, " %s\n", *i); + } } delete app_; -- 2.45.2