Compare commits

...

1 Commits

Author SHA1 Message Date
albexk
60975c9596 Add method to log nested exceptions 2024-09-10 00:24:05 +03:00
3 changed files with 24 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include "configurators/wireguard_configurator.h"
#include "core/enums/apiEnums.h"
#include "version.h"
#include "utilities.h"
namespace
{
@@ -362,6 +363,7 @@ ErrorCode ApiController::getConfigForService(const QString &installationUuid, co
publicKey = rsa.getPublicKeyFromByteArray(key);
} catch (...) {
qCritical() << "error loading public key from environment variables";
Utils::logException();
return ErrorCode::ApiMissingAgwPublicKey;
}

View File

@@ -211,6 +211,25 @@ QString Utils::tun2socksPath()
#endif
}
void Utils::logException(const std::exception &e)
{
qCritical() << e.what();
try {
std::rethrow_if_nested(e);
} catch (const std::exception &nested) {
logException(nested);
} catch (...) {}
}
void Utils::logException(const std::exception_ptr &eptr)
{
try {
if (eptr) std::rethrow_exception(eptr);
} catch (const std::exception &e) {
logException(e);
} catch (...) {}
}
#ifdef Q_OS_WIN
// Inspired from http://stackoverflow.com/a/15281070/1529139
// and http://stackoverflow.com/q/40059902/1529139

View File

@@ -34,6 +34,9 @@ public:
static QString certUtilPath();
static QString tun2socksPath();
static void logException(const std::exception &e);
static void logException(const std::exception_ptr &eptr = std::current_exception());
#ifdef Q_OS_WIN
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
#endif