better error reporting in email manager, because it seems it don't work like it should

This commit is contained in:
einhornimmond 2021-03-20 10:03:27 +01:00
parent a68cad4b87
commit bf35ff33ad
2 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}
}