#pragma once

#include "vertex_engine/utils/include.hpp" // IWYU pragma: keep

namespace VE
{
  struct event
  {
    event(std::any type, std::any data, std::string id = hack::security::generate_uuid()) : m_type{ type }, m_data{ data }, m_id { id } {}
    ~event() = default;

    std::any m_type;
    std::any m_data;
    std::any m_result;
    std::string m_id;
    std::string m_event_log_message;
    std::string m_event_id = hack::security::generate_uuid();

    template<typename T>
    T get_result()
    {
      T r;
      try { r = std::any_cast<T>(m_result); }
      catch(std::exception& e)
      {
        hack::exception ex;
        ex.service(e.what());
        ex.description("dont convert type any_cast");
        hack::error()(ex);
        throw ex;
      }

      return r;
    }
  };
}
