updated build system

This commit is contained in:
Scott E. Graves 2024-08-02 11:24:30 -05:00
parent b695200123
commit e66b783df8
4 changed files with 94 additions and 39 deletions

View File

@ -23,59 +23,71 @@
#define INCLUDE_UTILS_ERROR_UTILS_HPP_ #define INCLUDE_UTILS_ERROR_UTILS_HPP_
#include "types/repertory.hpp" #include "types/repertory.hpp"
#include "utils/error.hpp"
namespace repertory::utils::error { namespace repertory::utils::error {
void raise_error(std::string function, std::string_view msg); void raise_error(std::string_view function, std::string_view msg);
void raise_error(std::string function, const api_error &err, void raise_error(std::string_view function, const api_error &err,
std::string_view msg); std::string_view msg);
void raise_error(std::string function, const std::exception &exception, void raise_error(std::string_view function, const std::exception &exception);
void raise_error(std::string_view function, const std::exception &exception,
std::string_view msg); std::string_view msg);
void raise_error(std::string function, std::int64_t err, std::string_view msg); void raise_error(std::string_view function, std::int64_t err,
std::string_view msg);
void raise_error(std::string function, const json &err, std::string_view msg); void raise_error(std::string_view function, const json &err,
std::string_view msg);
void raise_error(std::string function, const api_error &err, void raise_error(std::string_view function, const api_error &err,
std::string_view file_path, std::string_view msg); std::string_view file_path, std::string_view msg);
void raise_error(std::string function, std::int64_t err, void raise_error(std::string_view function, std::int64_t err,
std::string_view file_path, std::string_view msg); std::string_view file_path, std::string_view msg);
void raise_error(std::string function, const std::exception &exception, void raise_error(std::string_view function, const std::exception &exception,
std::string_view file_path, std::string_view msg); std::string_view file_path, std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const api_error &err, std::string_view msg); const api_error &err, std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const std::exception &exception);
void raise_api_path_error(std::string_view function, std::string_view api_path,
const std::exception &exception, const std::exception &exception,
std::string_view msg); std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::int64_t err, std::string_view msg); std::int64_t err, std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const json &err, std::string_view msg); const json &err, std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, const api_error &err, std::string_view source_path, const api_error &err,
std::string_view msg); std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, std::int64_t err, std::string_view source_path, std::int64_t err,
std::string_view msg); std::string_view msg);
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, std::string_view source_path,
const std::exception &exception, const std::exception &exception,
std::string_view msg); std::string_view msg);
void raise_url_error(std::string function, std::string_view url, CURLcode err, void raise_url_error(std::string_view function, std::string_view url,
std::string_view msg); CURLcode err, std::string_view msg);
void raise_url_error(std::string function, std::string_view url, void raise_url_error(std::string_view function, std::string_view url,
std::string_view source_path,
const std::exception &exception);
void raise_url_error(std::string_view function, std::string_view url,
std::string_view source_path, std::string_view source_path,
const std::exception &exception, std::string_view msg); const std::exception &exception, std::string_view msg);

View File

@ -34,6 +34,7 @@
#include "utils/file_utils.hpp" #include "utils/file_utils.hpp"
#include "utils/path.hpp" #include "utils/path.hpp"
#include "utils/polling.hpp" #include "utils/polling.hpp"
#include "utils/time.hpp"
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace { namespace {
@ -505,8 +506,8 @@ void file_manager::queue_upload(const std::string &api_path,
db::db_insert{*db_.get(), upload_table} db::db_insert{*db_.get(), upload_table}
.or_replace() .or_replace()
.column_value("api_path", api_path) .column_value("api_path", api_path)
.column_value("date_time", .column_value("date_time", static_cast<std::int64_t>(
static_cast<std::int64_t>(utils::time::get_file_time_now())) utils::time::get_file_time_now()))
.column_value("source_path", source_path) .column_value("source_path", source_path)
.go(); .go();
if (result.ok()) { if (result.ok()) {

View File

@ -25,20 +25,41 @@
#include "events/events.hpp" #include "events/events.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
namespace {
struct repertory_exception_handler final
: repertory::utils::error::i_exception_handler {
void handle_exception(std::string_view function_name) const override {
repertory::utils::error::raise_error(function_name, "|exception|unknown");
}
void handle_exception(std::string_view function_name,
const std::exception &ex) const override {
repertory::utils::error::raise_error(function_name, ex);
}
};
} // namespace
namespace repertory::utils::error { namespace repertory::utils::error {
void raise_error(std::string function, std::string_view msg) { void raise_error(std::string_view function, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg)); function, static_cast<std::string>(msg));
} }
void raise_error(std::string function, const api_error &err, void raise_error(std::string_view function, const api_error &err,
std::string_view msg) { std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, function,
static_cast<std::string>(msg) + "|err|" + api_error_to_string(err)); static_cast<std::string>(msg) + "|err|" + api_error_to_string(err));
} }
void raise_error(std::string function, const std::exception &exception, void raise_error(std::string_view function, const std::exception &exception) {
event_system::instance().raise<repertory_exception>(
function,
"err|" + std::string(exception.what() == nullptr ? "unknown error"
: exception.what()));
}
void raise_error(std::string_view function, const std::exception &exception,
std::string_view msg) { std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, function,
@ -46,17 +67,19 @@ void raise_error(std::string function, const std::exception &exception,
(exception.what() == nullptr ? "unknown error" : exception.what())); (exception.what() == nullptr ? "unknown error" : exception.what()));
} }
void raise_error(std::string function, const json &err, std::string_view msg) { void raise_error(std::string_view function, const json &err,
std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|err|" + err.dump(2)); function, static_cast<std::string>(msg) + "|err|" + err.dump(2));
} }
void raise_error(std::string function, std::int64_t err, std::string_view msg) { void raise_error(std::string_view function, std::int64_t err,
std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|err|" + std::to_string(err)); function, static_cast<std::string>(msg) + "|err|" + std::to_string(err));
} }
void raise_error(std::string function, const api_error &err, void raise_error(std::string_view function, const api_error &err,
std::string_view file_path, std::string_view msg) { std::string_view file_path, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|sp|" + function, static_cast<std::string>(msg) + "|sp|" +
@ -64,7 +87,7 @@ void raise_error(std::string function, const api_error &err,
api_error_to_string(err)); api_error_to_string(err));
} }
void raise_error(std::string function, std::int64_t err, void raise_error(std::string_view function, std::int64_t err,
std::string_view file_path, std::string_view msg) { std::string_view file_path, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|sp|" + function, static_cast<std::string>(msg) + "|sp|" +
@ -72,7 +95,7 @@ void raise_error(std::string function, std::int64_t err,
std::to_string(err)); std::to_string(err));
} }
void raise_error(std::string function, const std::exception &exception, void raise_error(std::string_view function, const std::exception &exception,
std::string_view file_path, std::string_view msg) { std::string_view file_path, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, function,
@ -81,7 +104,7 @@ void raise_error(std::string function, const std::exception &exception,
(exception.what() == nullptr ? "unknown error" : exception.what())); (exception.what() == nullptr ? "unknown error" : exception.what()));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const api_error &err, std::string_view msg) { const api_error &err, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|ap|" + function, static_cast<std::string>(msg) + "|ap|" +
@ -89,7 +112,7 @@ void raise_api_path_error(std::string function, std::string_view api_path,
api_error_to_string(err)); api_error_to_string(err));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::int64_t err, std::string_view msg) { std::int64_t err, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|ap|" + function, static_cast<std::string>(msg) + "|ap|" +
@ -97,7 +120,15 @@ void raise_api_path_error(std::string function, std::string_view api_path,
std::to_string(err)); std::to_string(err));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const std::exception &exception) {
event_system::instance().raise<repertory_exception>(
function,
"ap|" + static_cast<std::string>(api_path) + "|err|" +
(exception.what() == nullptr ? "unknown error" : exception.what()));
}
void raise_api_path_error(std::string_view function, std::string_view api_path,
const std::exception &exception, const std::exception &exception,
std::string_view msg) { std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
@ -107,7 +138,7 @@ void raise_api_path_error(std::string function, std::string_view api_path,
(exception.what() == nullptr ? "unknown error" : exception.what())); (exception.what() == nullptr ? "unknown error" : exception.what()));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, const api_error &err, std::string_view source_path, const api_error &err,
std::string_view msg) { std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
@ -117,7 +148,7 @@ void raise_api_path_error(std::string function, std::string_view api_path,
api_error_to_string(err)); api_error_to_string(err));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, std::int64_t err, std::string_view source_path, std::int64_t err,
std::string_view msg) { std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
@ -127,14 +158,14 @@ void raise_api_path_error(std::string function, std::string_view api_path,
std::to_string(err)); std::to_string(err));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
const json &err, std::string_view msg) { const json &err, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|ap|" + function, static_cast<std::string>(msg) + "|ap|" +
static_cast<std::string>(api_path) + "|err|" + err.dump(2)); static_cast<std::string>(api_path) + "|err|" + err.dump(2));
} }
void raise_api_path_error(std::string function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path,
std::string_view source_path, std::string_view source_path,
const std::exception &exception, const std::exception &exception,
std::string_view msg) { std::string_view msg) {
@ -146,15 +177,25 @@ void raise_api_path_error(std::string function, std::string_view api_path,
(exception.what() == nullptr ? "unknown error" : exception.what())); (exception.what() == nullptr ? "unknown error" : exception.what()));
} }
void raise_url_error(std::string function, std::string_view url, CURLcode err, void raise_url_error(std::string_view function, std::string_view url,
std::string_view msg) { CURLcode err, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(
function, static_cast<std::string>(msg) + "|url|" + function, static_cast<std::string>(msg) + "|url|" +
static_cast<std::string>(url) + "|err|" + static_cast<std::string>(url) + "|err|" +
curl_easy_strerror(err)); curl_easy_strerror(err));
} }
void raise_url_error(std::string function, std::string_view url, void raise_url_error(std::string_view function, std::string_view url,
std::string_view source_path,
const std::exception &exception) {
event_system::instance().raise<repertory_exception>(
function,
"url|" + static_cast<std::string>(url) + "|sp|" +
static_cast<std::string>(source_path) + "|err|" +
(exception.what() == nullptr ? "unknown error" : exception.what()));
}
void raise_url_error(std::string_view function, std::string_view url,
std::string_view source_path, std::string_view source_path,
const std::exception &exception, std::string_view msg) { const std::exception &exception, std::string_view msg) {
event_system::instance().raise<repertory_exception>( event_system::instance().raise<repertory_exception>(

View File

@ -32,6 +32,7 @@
#include "mocks/mock_fuse_drive.hpp" #include "mocks/mock_fuse_drive.hpp"
#endif #endif
#include "types/repertory.hpp" #include "types/repertory.hpp"
#include "utils/time.hpp"
#include "utils/utils.hpp" #include "utils/utils.hpp"
using namespace repertory; using namespace repertory;
@ -429,7 +430,7 @@ static void set_basic_info_test(remote_client &client) {
const auto change_time = last_write_time; const auto change_time = last_write_time;
#else #else
const auto creation_time = const auto creation_time =
utils::unix_time_to_windows_time(utils::get_time_now()); utils::unix_time_to_windows_time(utils::time::get_time_now());
const auto last_access_time = creation_time + 1; const auto last_access_time = creation_time + 1;
const auto last_write_time = creation_time + 2; const auto last_write_time = creation_time + 2;
const auto change_time = last_write_time; const auto change_time = last_write_time;