updated build system
This commit is contained in:
		| @@ -23,59 +23,71 @@ | ||||
| #define INCLUDE_UTILS_ERROR_UTILS_HPP_ | ||||
|  | ||||
| #include "types/repertory.hpp" | ||||
| #include "utils/error.hpp" | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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, | ||||
|                           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); | ||||
|  | ||||
| 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); | ||||
|  | ||||
| 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 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 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 std::exception &exception, | ||||
|                           std::string_view msg); | ||||
|  | ||||
| void raise_url_error(std::string function, std::string_view url, CURLcode err, | ||||
|                      std::string_view msg); | ||||
| void raise_url_error(std::string_view function, std::string_view url, | ||||
|                      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, | ||||
|                      const std::exception &exception, std::string_view msg); | ||||
|  | ||||
|   | ||||
| @@ -34,6 +34,7 @@ | ||||
| #include "utils/file_utils.hpp" | ||||
| #include "utils/path.hpp" | ||||
| #include "utils/polling.hpp" | ||||
| #include "utils/time.hpp" | ||||
| #include "utils/utils.hpp" | ||||
|  | ||||
| namespace { | ||||
| @@ -505,8 +506,8 @@ void file_manager::queue_upload(const std::string &api_path, | ||||
|       db::db_insert{*db_.get(), upload_table} | ||||
|           .or_replace() | ||||
|           .column_value("api_path", api_path) | ||||
|           .column_value("date_time", | ||||
|                         static_cast<std::int64_t>(utils::time::get_file_time_now())) | ||||
|           .column_value("date_time", static_cast<std::int64_t>( | ||||
|                                          utils::time::get_file_time_now())) | ||||
|           .column_value("source_path", source_path) | ||||
|           .go(); | ||||
|   if (result.ok()) { | ||||
|   | ||||
| @@ -25,20 +25,41 @@ | ||||
| #include "events/events.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 { | ||||
| 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>( | ||||
|       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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, | ||||
|       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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, | ||||
| @@ -46,17 +67,19 @@ void raise_error(std::string function, const std::exception &exception, | ||||
|           (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>( | ||||
|       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>( | ||||
|       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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       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)); | ||||
| } | ||||
|  | ||||
| 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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       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)); | ||||
| } | ||||
|  | ||||
| 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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, | ||||
| @@ -81,7 +104,7 @@ void raise_error(std::string function, const std::exception &exception, | ||||
|           (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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       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)); | ||||
| } | ||||
|  | ||||
| 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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       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)); | ||||
| } | ||||
|  | ||||
| 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, | ||||
|                           std::string_view msg) { | ||||
|   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())); | ||||
| } | ||||
|  | ||||
| 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 msg) { | ||||
|   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)); | ||||
| } | ||||
|  | ||||
| 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 msg) { | ||||
|   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)); | ||||
| } | ||||
|  | ||||
| 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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, static_cast<std::string>(msg) + "|ap|" + | ||||
|                     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, | ||||
|                           const std::exception &exception, | ||||
|                           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())); | ||||
| } | ||||
|  | ||||
| void raise_url_error(std::string function, std::string_view url, CURLcode err, | ||||
|                      std::string_view msg) { | ||||
| void raise_url_error(std::string_view function, std::string_view url, | ||||
|                      CURLcode err, std::string_view msg) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, static_cast<std::string>(msg) + "|url|" + | ||||
|                     static_cast<std::string>(url) + "|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, | ||||
|                      const std::exception &exception, std::string_view msg) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|   | ||||
| @@ -32,6 +32,7 @@ | ||||
| #include "mocks/mock_fuse_drive.hpp" | ||||
| #endif | ||||
| #include "types/repertory.hpp" | ||||
| #include "utils/time.hpp" | ||||
| #include "utils/utils.hpp" | ||||
|  | ||||
| using namespace repertory; | ||||
| @@ -429,7 +430,7 @@ static void set_basic_info_test(remote_client &client) { | ||||
|   const auto change_time = last_write_time; | ||||
| #else | ||||
|   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_write_time = creation_time + 2; | ||||
|   const auto change_time = last_write_time; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user