logic: improve logging if exception occurred while loading project (#1004)

This commit is contained in:
Malte Langkabel
2020-05-08 16:09:29 +02:00
committed by GitHub
parent f86a4afdc5
commit 8a75946c73
2 changed files with 30 additions and 12 deletions
+19 -11
View File
@@ -32,6 +32,8 @@
#include "utilityString.h"
#include "utilityUuid.h"
#include "CppSQLite3.h"
std::shared_ptr<Application> Application::s_instance;
std::string Application::s_uuid;
@@ -306,20 +308,26 @@ void Application::handleMessage(MessageLoadProject* message)
}
catch (std::exception& e)
{
LOG_ERROR_STREAM(<< "Failed to load project, exception thrown: " << e.what());
MessageStatus(
L"Failed to load project, exception was thrown: " + projectSettingsFilePath.wstr(),
true)
.dispatch();
const std::wstring message = L"Failed to load project at \"" +
projectSettingsFilePath.wstr() + L"\" with exception: " +
utility::decodeFromUtf8(e.what());
LOG_ERROR(message);
MessageStatus(message, true).dispatch();
}
catch (CppSQLite3Exception& e)
{
const std::wstring message = L"Failed to load project at \"" +
projectSettingsFilePath.wstr() + L"\" with sqlite exception: " +
utility::decodeFromUtf8(e.errorMessage());
LOG_ERROR(message);
MessageStatus(message, true).dispatch();
}
catch (...)
{
LOG_ERROR_STREAM(<< "Failed to load project, unknown exception thrown.");
MessageStatus(
L"Failed to load project, unknown exception was thrown: " +
projectSettingsFilePath.wstr(),
true)
.dispatch();
const std::wstring message = L"Failed to load project at \"" +
projectSettingsFilePath.wstr() + L"\" with unknown exception.";
LOG_ERROR(message);
MessageStatus(message, true).dispatch();
}
if (message->refreshMode != REFRESH_NONE)
+11 -1
View File
@@ -12,7 +12,17 @@ SqliteStorage::SqliteStorage(const FilePath& dbFilePath): m_dbFilePath(dbFilePat
FileSystem::createDirectory(m_dbFilePath.getParentDirectory());
}
m_database.open(utility::encodeToUtf8(m_dbFilePath.wstr()).c_str());
try
{
m_database.open(utility::encodeToUtf8(m_dbFilePath.wstr()).c_str());
}
catch (CppSQLite3Exception& e)
{
LOG_ERROR(
L"Failed to load database file \"" + m_dbFilePath.wstr() + L"\" with message: " +
utility::decodeFromUtf8(e.errorMessage()));
throw;
}
executeStatement("PRAGMA foreign_keys=ON;");
}