diff --git a/include/comm/curl/curl_comm.hpp b/include/comm/curl/curl_comm.hpp index 77c3c2b9..9214fb2f 100644 --- a/include/comm/curl/curl_comm.hpp +++ b/include/comm/curl/curl_comm.hpp @@ -24,6 +24,8 @@ #include "comm/curl/multi_request.hpp" #include "comm/i_http_comm.hpp" +#include "events/event_system.hpp" +#include "events/events.hpp" #include "utils/encryption.hpp" #include "utils/utils.hpp" @@ -196,7 +198,7 @@ public: CURLcode curl_code{}; curl_request.get_result(curl_code, response_code); if (curl_code != CURLE_OK) { - std::cout << curl_easy_strerror(curl_code) << std::endl; + event_system::instance().raise(url, curl_code); return false; } diff --git a/include/events/event_system.hpp b/include/events/event_system.hpp index ada61017..d543f6a7 100644 --- a/include/events/event_system.hpp +++ b/include/events/event_system.hpp @@ -60,6 +60,7 @@ using event_consumer = event_system::event_consumer; return ss; \ })(d) #define E_STRING(t) t +#define E_FROM_CURL_CODE(t) std::string(curl_easy_strerror(t)) #define E_FROM_UINT8(t) std::to_string(t) #define E_FROM_UINT32(t) std::to_string(t) #define E_FROM_UINT64(t) std::to_string(t) diff --git a/include/events/events.hpp b/include/events/events.hpp index cb68ca5e..6c945d77 100644 --- a/include/events/events.hpp +++ b/include/events/events.hpp @@ -28,145 +28,9 @@ namespace repertory { // clang-format off -E_SIMPLE3(cache_file_processed, normal, true, - std::string, api_path, ap, E_STRING, - std::string, source, src, E_STRING, - api_error, result, res, E_FROM_API_FILE_ERROR -); - -E_SIMPLE2(comm_auth_begin, normal, true, +E_SIMPLE2(curl_error, normal, true, std::string, url, url, E_STRING, - std::string, user, user, E_STRING -); - -E_SIMPLE4(comm_auth_end, normal, true, - std::string, url, url, E_STRING, - std::string, user, user, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32 -); - -E_SIMPLE2(comm_auth_logout_begin, normal, true, - std::string, url, url, E_STRING, - std::string, user, user, E_STRING -); - -E_SIMPLE4(comm_auth_logout_end, normal, true, - std::string, url, url, E_STRING, - std::string, user, user, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32 -); - -E_SIMPLE1(comm_del_begin, verbose, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_del_end, verbose, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, result, res, E_STRING -); - -E_SIMPLE1(comm_get_begin, verbose, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_get_end, verbose, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, result, res, E_STRING -); - -E_SIMPLE1(comm_get_range_begin, verbose, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_get_range_end, verbose, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, error, err, E_STRING -); - -E_SIMPLE1(comm_get_raw_begin, verbose, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_get_raw_end, verbose, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, error, err, E_STRING -); - -E_SIMPLE2(comm_post_begin, verbose, true, - std::string, url, url, E_STRING, - std::string, fields, fields, E_STRING -); - -E_SIMPLE4(comm_post_end, verbose, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, result, res, E_STRING -); - -E_SIMPLE2(comm_duration, normal, true, - std::string, url, url, E_STRING, - std::string, duration, duration, E_STRING -); - -E_SIMPLE1(comm_post_file_begin, debug, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_post_file_end, debug, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, error, err, E_STRING -); - -E_SIMPLE1(comm_post_multi_part_file_begin, debug, true, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_post_multi_part_file_end, debug, true, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32, - std::string, error, err, E_STRING -); - -E_SIMPLE4(comm_tus_upload_begin, debug, true, - std::string, file_name, fn, E_STRING, - std::string, url, url, E_STRING, - std::uint64_t, remain, rem, E_FROM_UINT64, - std::uint64_t, offset, off, E_FROM_UINT64 -); - -E_SIMPLE6(comm_tus_upload_end, debug, true, - std::string, file_name, fn, E_STRING, - std::string, url, url, E_STRING, - std::uint64_t, remain, rem, E_FROM_UINT64, - std::uint64_t, offset, OFF, E_FROM_UINT64, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32 -); - -E_SIMPLE2(comm_tus_upload_create_begin, debug, true, - std::string, file_name, fn, E_STRING, - std::string, url, url, E_STRING -); - -E_SIMPLE4(comm_tus_upload_create_end, debug, true, - std::string, file_name, fn, E_STRING, - std::string, url, url, E_STRING, - CURLcode, curl, curl, E_FROM_INT32, - int, http, http, E_FROM_INT32 + CURLcode, res, res, E_FROM_CURL_CODE ); E_SIMPLE3(debug_log, debug, true,