diff --git a/src/lib/app/Application.cpp b/src/lib/app/Application.cpp index d8cd35c98..3ecc19e0c 100644 --- a/src/lib/app/Application.cpp +++ b/src/lib/app/Application.cpp @@ -32,6 +32,8 @@ #include "utilityString.h" #include "utilityUuid.h" +#include "CppSQLite3.h" + std::shared_ptr 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) diff --git a/src/lib/data/storage/sqlite/SqliteStorage.cpp b/src/lib/data/storage/sqlite/SqliteStorage.cpp index 90b527f43..957b84b1f 100644 --- a/src/lib/data/storage/sqlite/SqliteStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteStorage.cpp @@ -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;"); }