From bf35ff33ad486c8181adee9b721eec07ca36e2ed Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Sat, 20 Mar 2021 10:03:27 +0100 Subject: [PATCH] better error reporting in email manager, because it seems it don't work like it should --- login_server/src/cpp/SingletonManager/EmailManager.cpp | 4 ++++ login_server/src/cpp/tasks/Thread.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/login_server/src/cpp/SingletonManager/EmailManager.cpp b/login_server/src/cpp/SingletonManager/EmailManager.cpp index 847887316..e1eee3e2c 100644 --- a/login_server/src/cpp/SingletonManager/EmailManager.cpp +++ b/login_server/src/cpp/SingletonManager/EmailManager.cpp @@ -92,6 +92,8 @@ int EmailManager::ThreadFunction() if (mPendingEmails.empty()) return 0; auto lm = LanguageManager::getInstance(); + ErrorList errors; + static const char* function_name = "PrepareEmailTask"; Poco::Net::SecureSMTPClientSession mailClientSession(mEmailAccount.url, mEmailAccount.port); mailClientSession.login(); @@ -100,6 +102,7 @@ int EmailManager::ThreadFunction() mailClientSession.login(Poco::Net::SMTPClientSession::AUTH_LOGIN, mEmailAccount.username, mEmailAccount.password); } catch (Poco::Net::SSLException& ex) { + errors.addError(new ParamError(function_name, "ssl certificate error", ex.displayText())); printf("[PrepareEmailTask] ssl certificate error: %s\nPlease make sure you have cacert.pem (CA/root certificates) next to binary from https://curl.haxx.se/docs/caextract.html\n", ex.displayText().data()); return -1; } @@ -151,6 +154,7 @@ int EmailManager::ThreadFunction() else { // error drafting email, shouldn't happend printf("[EmailManager::ThreadFunction] Error drafting email\n"); + errors.addError(new Error(function_name, "Error drafting email")); } delete email; email = nullptr; diff --git a/login_server/src/cpp/tasks/Thread.cpp b/login_server/src/cpp/tasks/Thread.cpp index 0c095aeb9..2419a1719 100644 --- a/login_server/src/cpp/tasks/Thread.cpp +++ b/login_server/src/cpp/tasks/Thread.cpp @@ -1,6 +1,7 @@ //#include "lib/Thread.h" //#include "UniversumLib.h" #include "Thread.h" +#include "../lib/ErrorList.h" namespace UniLib { namespace lib { @@ -55,6 +56,8 @@ namespace UniLib { void Thread::run() { + static const char* function_name = "Thread::run"; + ErrorList errors; //Thread* t = this; while (true) { try { @@ -77,6 +80,7 @@ namespace UniLib { { //EngineLog.writeToLog("error-code: %d", ret); printf("[Thread::%s] error running thread functon: %d, exit thread\n", __FUNCTION__, ret); + errors.addError(new ParamError(function_name, "error running thread function, exit thread", mPocoThread->getName())); return; } } @@ -85,13 +89,19 @@ namespace UniLib { threadUnlock(); //LOG_ERROR("Fehler in Thread, exit", -1); printf("[Thread::%s] exception: %s\n", __FUNCTION__, e.message().data()); + errors.addError(new ParamError(function_name, "poco exception", e.message())); + errors.addError(new ParamError(function_name, "thread name", mPocoThread->getName())); return; } } catch (Poco::TimeoutException& e) { printf("[Thread::%s] timeout exception\n", __FUNCTION__); + errors.addError(new ParamError(function_name, "poco timeout exception", e.message())); + errors.addError(new ParamError(function_name, "thread name", mPocoThread->getName())); } catch (Poco::Exception& e) { printf("[Thread::%s] exception: %s\n", __FUNCTION__, e.message().data()); + errors.addError(new ParamError(function_name, "poco exception 2", e.message())); + errors.addError(new ParamError(function_name, "thread name", mPocoThread->getName())); return; } }