Demangling exception class name from error message of unknown exceptions.
authorMartín Ferrari <tincho@tincho.org>
Sun, 27 Aug 2017 21:04:57 +0000 (23:04 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 30 Aug 2017 17:41:28 +0000 (19:41 +0200)
src/app/application.cpp

index e8ad62b..386b681 100644 (file)
@@ -41,13 +41,17 @@ bool Application::notify(QObject* receiver, QEvent* event)
         error_message("UNCAUGHT exception: " + QString(e.what()));
         return false;
     } catch (...) {
-        error_message("UNCAUGHT exception: " +
 #if defined(__GNUC__) || defined(__llvm__) || defined(__clang__)
-                QString(__cxxabiv1::__cxa_current_exception_type()->name())
+        int status = 0;
+        char *buff = __cxxabiv1::__cxa_demangle(
+                __cxxabiv1::__cxa_current_exception_type()->name(),
+                NULL, NULL, &status);
+        QString exception_name = QString(buff);
+        std::free(buff);
 #else
-                "unknown"
+        QString exception_name = QString("unknown");
 #endif
-                );
+        error_message("UNCAUGHT exception: " + exception_name);
         return false;
     }
 }