updated build system
This commit is contained in:
		| @@ -24,6 +24,8 @@ | ||||
| #include "events/event_system.hpp" | ||||
| #include "events/events.hpp" | ||||
| #include "types/repertory.hpp" | ||||
| #include "utils/error.hpp" | ||||
| #include <memory> | ||||
|  | ||||
| namespace { | ||||
| struct repertory_exception_handler final | ||||
| @@ -37,24 +39,30 @@ struct repertory_exception_handler final | ||||
|     repertory::utils::error::raise_error(function_name, ex); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| static std::unique_ptr<repertory_exception_handler> handler{([]() -> auto * { | ||||
|   auto *ptr = new repertory_exception_handler{}; | ||||
|   repertory::utils::error::set_exception_handler(ptr); | ||||
|   return ptr; | ||||
| })()}; | ||||
| } // namespace | ||||
|  | ||||
| namespace repertory::utils::error { | ||||
| void raise_error(std::string_view function, std::string_view msg) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, static_cast<std::string>(msg)); | ||||
|       static_cast<std::string>(function), static_cast<std::string>(msg)); | ||||
| } | ||||
|  | ||||
| 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>(function), | ||||
|       static_cast<std::string>(msg) + "|err|" + api_error_to_string(err)); | ||||
| } | ||||
|  | ||||
| void raise_error(std::string_view function, const std::exception &exception) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, | ||||
|       static_cast<std::string>(function), | ||||
|       "err|" + std::string(exception.what() == nullptr ? "unknown error" | ||||
|                                                        : exception.what())); | ||||
| } | ||||
| @@ -62,7 +70,7 @@ 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) { | ||||
|   event_system::instance().raise<repertory_exception>( | ||||
|       function, | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
| } | ||||
| @@ -70,19 +78,22 @@ void raise_error(std::string_view function, const std::exception &exception, | ||||
| 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)); | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|err|" + err.dump(2)); | ||||
| } | ||||
|  | ||||
| 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)); | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|err|" + std::to_string(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|" + | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|sp|" + | ||||
|           static_cast<std::string>(file_path) + "|err|" + | ||||
|           api_error_to_string(err)); | ||||
| } | ||||
| @@ -90,15 +101,15 @@ void raise_error(std::string_view function, const api_error &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|" + | ||||
|                     static_cast<std::string>(file_path) + "|err|" + | ||||
|                     std::to_string(err)); | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|sp|" + | ||||
|           static_cast<std::string>(file_path) + "|err|" + std::to_string(err)); | ||||
| } | ||||
|  | ||||
| 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, | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|sp|" + | ||||
|           static_cast<std::string>(file_path) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
| @@ -107,7 +118,8 @@ void raise_error(std::string_view function, const std::exception &exception, | ||||
| 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|" + | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|err|" + | ||||
|           api_error_to_string(err)); | ||||
| } | ||||
| @@ -115,15 +127,15 @@ void raise_api_path_error(std::string_view 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|" + | ||||
|                     static_cast<std::string>(api_path) + "|err|" + | ||||
|                     std::to_string(err)); | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|err|" + std::to_string(err)); | ||||
| } | ||||
|  | ||||
| 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, | ||||
|       static_cast<std::string>(function), | ||||
|       "ap|" + static_cast<std::string>(api_path) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
| } | ||||
| @@ -132,7 +144,7 @@ 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>( | ||||
|       function, | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
| @@ -142,7 +154,8 @@ 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>( | ||||
|       function, static_cast<std::string>(msg) + "|ap|" + | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|sp|" + | ||||
|           static_cast<std::string>(source_path) + "|err|" + | ||||
|           api_error_to_string(err)); | ||||
| @@ -152,7 +165,8 @@ 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>( | ||||
|       function, static_cast<std::string>(msg) + "|ap|" + | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|sp|" + | ||||
|           static_cast<std::string>(source_path) + "|err|" + | ||||
|           std::to_string(err)); | ||||
| @@ -161,7 +175,8 @@ void raise_api_path_error(std::string_view 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>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|err|" + err.dump(2)); | ||||
| } | ||||
|  | ||||
| @@ -170,7 +185,7 @@ 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>( | ||||
|       function, | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|ap|" + | ||||
|           static_cast<std::string>(api_path) + "|sp|" + | ||||
|           static_cast<std::string>(source_path) + "|err|" + | ||||
| @@ -180,16 +195,16 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, | ||||
| 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)); | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|url|" + static_cast<std::string>(url) + | ||||
|           "|err|" + curl_easy_strerror(err)); | ||||
| } | ||||
|  | ||||
| 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, | ||||
|       static_cast<std::string>(function), | ||||
|       "url|" + static_cast<std::string>(url) + "|sp|" + | ||||
|           static_cast<std::string>(source_path) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
| @@ -199,7 +214,7 @@ 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>( | ||||
|       function, | ||||
|       static_cast<std::string>(function), | ||||
|       static_cast<std::string>(msg) + "|url|" + static_cast<std::string>(url) + | ||||
|           "|sp|" + static_cast<std::string>(source_path) + "|err|" + | ||||
|           (exception.what() == nullptr ? "unknown error" : exception.what())); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user