refactor event system

This commit is contained in:
2025-01-24 08:32:00 -06:00
parent 993356dec6
commit ebdc4877a8

View File

@ -28,7 +28,7 @@
namespace repertory {
struct file_upload_retry final : public i_event {
file_upload_retry() = default;
file_upload_retry(std::string api_path_, std::string error_,
file_upload_retry(std::string api_path_, api_error error_,
std::string_view function_name_, std::string source_path_)
: api_path(std::move(api_path_)),
error(std::move(error_)),
@ -39,7 +39,7 @@ struct file_upload_retry final : public i_event {
static constexpr const std::string_view name{"file_upload_retry"};
std::string api_path;
std::string error;
api_error error{};
std::string function_name;
std::string source_path;
@ -52,8 +52,8 @@ struct file_upload_retry final : public i_event {
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|error|{}|sp|{}", name, function_name,
api_path, error, source_path);
return fmt::format("{}|func|{}|ap|{}|sp|{}|error|{}", name, function_name,
api_path, source_path, api_error_to_string(error));
}
};
} // namespace repertory
@ -62,14 +62,15 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::file_upload_retry> {
static void to_json(json &data, const repertory::file_upload_retry &value) {
data["api_path"] = value.api_path;
data["error"] = value.error;
data["error"] = repertory::api_error_to_string(value.error);
data["function_name"] = value.function_name;
data["source_path"] = value.source_path;
}
static void from_json(const json &data, repertory::file_upload_retry &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("error").get_to<std::string>(value.error);
value.error =
repertory::api_error_from_string(data.at("error").get<std::string>());
data.at("function_name").get_to<std::string>(value.function_name);
data.at("source_path").get_to<std::string>(value.source_path);
}