logic: improve logging if exception occurred while loading project (#1004)
This commit is contained in:
+19
-11
@@ -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)
|
||||
|
||||
@@ -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;");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user