From: Mikko Rasa Date: Fri, 19 Feb 2021 23:15:52 +0000 (+0200) Subject: Nicer formatting of exceptions with multi-line whats X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9c8bb278a26c0c4356d6ee5e66d3f34c70521fb8;p=libs%2Fcore.git Nicer formatting of exceptions with multi-line whats --- 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_;