Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33262591
D14562.1768607977.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
15 KB
Referenced Files
None
Subscribers
None
D14562.1768607977.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp
@@ -1,5 +1,6 @@
#include "NativeSQLiteConnectionManager.h"
#include "AESCrypto.h"
+#include "Logger.h"
#include "PlatformSpecificTools.h"
#include <fstream>
@@ -51,7 +52,10 @@
tempFilePath, std::ofstream::out | std::ofstream::trunc);
if (!tempFile.is_open()) {
- throw std::runtime_error("Failed to open temporary log file.");
+ std::string errorMessage{
+ "Failed to open temporary file when persisting log"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
std::vector<std::uint8_t> logBytes(patchsetPtr, patchsetPtr + patchsetSize);
@@ -70,9 +74,11 @@
tempFile.close();
if (std::rename(tempFilePath.c_str(), finalFilePath.c_str())) {
- throw std::runtime_error(
- "Failed to rename complete log file from temporary path to target "
- "path.");
+ std::string errorMessage{
+ "Failed to rename complete log file from temporary path to target when "
+ "persisting log"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
std::vector<std::string> attachments =
@@ -89,7 +95,10 @@
tempAttachmentsPath, std::ofstream::out | std::ofstream::trunc);
if (!tempAttachmentsFile.is_open()) {
- throw std::runtime_error("Failed to open temporary log attachments file.");
+ std::string errorMessage{
+ "Failed to open temporary log attachments file when persisting log"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
for (const auto &attachment : attachments) {
@@ -98,10 +107,11 @@
tempAttachmentsFile.close();
if (std::rename(tempAttachmentsPath.c_str(), finalAttachmentsPath.c_str())) {
- throw std::runtime_error(
+ std::string errorMessage{
"Failed to rename complete log attachments file from temporary path to "
- "target "
- "path.");
+ "target path when persisting log"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
}
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp
@@ -60,9 +60,11 @@
void SQLiteConnectionManager::restoreFromBackupLog(
const std::vector<std::uint8_t> &backupLog) {
if (!dbConnection) {
- throw std::runtime_error(
- "Programmer error: attempt to restore from backup log but database "
- "connection is not initialized.");
+ std::string errorMessage{
+ "Programmer error: attempt to restore from backup log, but database "
+ "connection is not initialized"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
static auto backupLogRestoreConflictHandler =
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -1061,6 +1061,7 @@
if (error_set_key) {
std::ostringstream error_message;
error_message << "Failed to set encryption key: " << error_set_key;
+ Logger::log(error_message.str());
throw std::system_error(
ECANCELED, std::generic_category(), error_message.str());
}
@@ -1124,7 +1125,10 @@
const std::string &file_path,
const char *error_message) {
if (std::remove(file_path.c_str())) {
- throw std::system_error(errno, std::generic_category(), error_message);
+ std::string message =
+ std::string("Error when deleting file ") + error_message;
+ Logger::log(message);
+ throw std::system_error(errno, std::generic_category(), message);
}
}
@@ -1133,7 +1137,10 @@
const std::string &new_path,
const char *error_message) {
if (std::rename(old_path.c_str(), new_path.c_str())) {
- throw std::system_error(errno, std::generic_category(), error_message);
+ std::string message =
+ std::string("Error when renaming file ") + error_message;
+ Logger::log(message);
+ throw std::system_error(errno, std::generic_category(), message);
}
}
@@ -1222,10 +1229,10 @@
db, createEncryptedCopySQL.c_str(), nullptr, nullptr, &encryption_error);
if (encryption_error) {
- throw std::system_error(
- ECANCELED,
- std::generic_category(),
- "Failed to create encrypted copy of the original database.");
+ std::string error{
+ "Failed to create encrypted copy of the original database"};
+ Logger::log(error);
+ throw std::system_error(ECANCELED, std::generic_category(), error);
}
sqlite3_close(db);
@@ -1714,6 +1721,7 @@
std::stringstream error_message;
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -2459,9 +2467,11 @@
crypto::Persist persist) const {
if (accountID != CONTENT_ACCOUNT_ID && persist.sessions.size() > 0) {
- throw std::runtime_error(
+ std::string errorMessage{
"Attempt to store notifications sessions in SQLite. Notifications "
- "sessions must be stored in storage shared with NSE.");
+ "sessions must be stored in storage shared with NSE"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
std::string accountData =
@@ -2708,6 +2718,7 @@
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
sqlite3_finalize(preparedUpdateSQL);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
@@ -2905,6 +2916,7 @@
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
sqlite3_finalize(preparedSQL);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
@@ -3059,6 +3071,7 @@
std::ostringstream errorStream;
errorStream << "Failed to delete database file. Details: "
<< strerror(errno);
+ Logger::log(errorStream.str());
throw std::system_error(errno, std::generic_category(), errorStream.str());
}
SQLiteQueryExecutor::generateBackupDataKey();
@@ -3174,6 +3187,7 @@
error_message << "Failed to init backup for main compaction. Details: "
<< sqlite3_errmsg(backupDB) << std::endl;
sqlite3_close(backupDB);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -3188,6 +3202,7 @@
std::stringstream error_message;
error_message << "Failed to create database backup. Details: "
<< sqlite3_errstr(backupResult);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -3203,8 +3218,10 @@
std::ofstream tempAttachmentsFile(tempAttachmentsPath);
if (!tempAttachmentsFile.is_open()) {
- throw std::runtime_error(
- "Unable to create attachments file for backup id: " + backupID);
+ std::string errorMessage{
+ "Unable to create attachments file for backup id: " + backupID};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
std::string getAllBlobServiceMediaSQL =
@@ -3337,13 +3354,17 @@
std::string maxVersion) const {
if (!file_exists(mainCompactionPath)) {
- throw std::runtime_error("Restore attempt but backup file does not exist.");
+ std::string errorMessage{"Restore attempt but backup file does not exist"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
sqlite3 *backupDB;
if (!is_database_queryable(
backupDB, true, mainCompactionPath, mainCompactionEncryptionKey)) {
- throw std::runtime_error("Backup file or encryption key corrupted.");
+ std::string errorMessage{"Backup file or encryption key corrupted"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
std::string plaintextBackupPath = mainCompactionPath + "_plaintext";
@@ -3376,6 +3397,7 @@
<< " that is newer than the max supported version "
<< maxVersion << std::endl;
sqlite3_close(backupDB);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h b/native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h
--- a/native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h
@@ -1,7 +1,9 @@
#pragma once
+#include "Logger.h"
#include "SQLiteDataConverters.h"
#include "SQLiteStatementWrapper.h"
+
#include <iostream>
#include <sstream>
#include <vector>
@@ -33,6 +35,7 @@
std::stringstream error_message;
error_message << "Failed to fetch row by primary key. Details: "
<< sqlite3_errstr(stepResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -52,6 +55,7 @@
std::stringstream error_message;
error_message << "Failed to bind primary key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -70,6 +74,7 @@
std::stringstream error_message;
error_message << "Failed to bind primary key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
return getEntityByPrimaryKeyCommon<T>(preparedSQL);
@@ -90,6 +95,7 @@
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
sqlite3_finalize(preparedSQL);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
@@ -114,6 +120,7 @@
std::stringstream error_message;
error_message << "Failed to bind entity to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -139,6 +146,7 @@
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
sqlite3_finalize(preparedSQL);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
@@ -161,6 +169,7 @@
std::stringstream error_message;
error_message << "Failed to bind key to SQL statement. Details: "
<< sqlite3_errstr(bindResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
@@ -184,6 +193,7 @@
std::stringstream error_message;
error_message << "Failed to execute query. Details: " << err << std::endl;
sqlite3_free(err);
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/SQLiteStatementWrapper.cpp b/native/cpp/CommonCpp/DatabaseManagers/entities/SQLiteStatementWrapper.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/entities/SQLiteStatementWrapper.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/SQLiteStatementWrapper.cpp
@@ -1,5 +1,7 @@
#include "SQLiteStatementWrapper.h"
+#include "Logger.h"
+
#include <sstream>
#include <stdexcept>
#include <system_error>
@@ -16,6 +18,7 @@
std::stringstream error_message;
error_message << "Failed to prepare SQL statement. Details: "
<< sqlite3_errstr(prepareSQLResult) << std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
onLastStepFailureMessage = onLastStepFailureMessage;
@@ -28,6 +31,7 @@
error_message << onLastStepFailureMessage
<< " Details: " << sqlite3_errstr(lastStepResult)
<< std::endl;
+ Logger::log(error_message.str());
throw std::runtime_error(error_message.str());
}
}
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -5,6 +5,7 @@
#include "DatabaseManager.h"
#include "InternalModules/GlobalDBSingleton.h"
#include "InternalModules/RustPromiseManager.h"
+#include "Logger.h"
#include "NativeModuleUtils.h"
#include "TerminateApp.h"
@@ -846,17 +847,23 @@
try {
parsedPrekey = folly::parseJson(prekeyBlob);
} catch (const folly::json::parse_error &e) {
- throw std::runtime_error(
- "parsing prekey failed with: " + std::string(e.what()));
+ std::string errorMessage{
+ "parsing prekey failed with: " + std::string(e.what())};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
folly::dynamic innerObject = parsedPrekey["curve25519"];
if (!innerObject.isObject()) {
- throw std::runtime_error("parsing prekey failed: inner object malformed");
+ std::string errorMessage{"parsing prekey failed: inner object malformed"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
if (innerObject.values().begin() == innerObject.values().end()) {
- throw std::runtime_error("parsing prekey failed: prekey missing");
+ std::string errorMessage{"parsing prekey failed: prekey missing"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
return parsedPrekey["curve25519"].values().begin()->asString();
diff --git a/native/cpp/CommonCpp/Tools/WorkerThread.cpp b/native/cpp/CommonCpp/Tools/WorkerThread.cpp
--- a/native/cpp/CommonCpp/Tools/WorkerThread.cpp
+++ b/native/cpp/CommonCpp/Tools/WorkerThread.cpp
@@ -21,8 +21,10 @@
void WorkerThread::scheduleTask(const taskType task) {
if (!this->tasks.write(std::make_unique<taskType>(std::move(task)))) {
- throw std::runtime_error(
- "Error scheduling task on the " + this->name + " worker thread");
+ std::string errorMessage{
+ "Error scheduling task on the " + this->name + " worker thread"};
+ Logger::log(errorMessage);
+ throw std::runtime_error(errorMessage);
}
}
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 11:59 PM (16 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5946494
Default Alt Text
D14562.1768607977.diff (15 KB)
Attached To
Mode
D14562: [native][SQLite] add logging to errors
Attached
Detach File
Event Timeline
Log In to Comment