refactor(eventsub): enforce static error categories (#5903)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
@@ -12,18 +12,14 @@ boost::json::result_for<Badge, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Badge must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsetID = root.if_contains("set_id");
|
||||
if (jvsetID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_setID{
|
||||
"Missing required key set_id"};
|
||||
return boost::system::error_code{129, error_missing_field_setID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto setID = boost::json::try_value_to<std::string>(*jvsetID);
|
||||
@@ -36,9 +32,7 @@ boost::json::result_for<Badge, boost::json::value>::type tag_invoke(
|
||||
const auto *jvid = root.if_contains("id");
|
||||
if (jvid == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_id{
|
||||
"Missing required key id"};
|
||||
return boost::system::error_code{129, error_missing_field_id};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto id = boost::json::try_value_to<std::string>(*jvid);
|
||||
@@ -51,9 +45,7 @@ boost::json::result_for<Badge, boost::json::value>::type tag_invoke(
|
||||
const auto *jvinfo = root.if_contains("info");
|
||||
if (jvinfo == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_info{
|
||||
"Missing required key info"};
|
||||
return boost::system::error_code{129, error_missing_field_info};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto info = boost::json::try_value_to<std::string>(*jvinfo);
|
||||
@@ -75,18 +67,14 @@ boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Cheermote must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvprefix = root.if_contains("prefix");
|
||||
if (jvprefix == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_prefix{
|
||||
"Missing required key prefix"};
|
||||
return boost::system::error_code{129, error_missing_field_prefix};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto prefix = boost::json::try_value_to<std::string>(*jvprefix);
|
||||
@@ -99,9 +87,7 @@ boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
const auto *jvbits = root.if_contains("bits");
|
||||
if (jvbits == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_bits{
|
||||
"Missing required key bits"};
|
||||
return boost::system::error_code{129, error_missing_field_bits};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto bits = boost::json::try_value_to<int>(*jvbits);
|
||||
@@ -114,9 +100,7 @@ boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
const auto *jvtier = root.if_contains("tier");
|
||||
if (jvtier == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_tier{
|
||||
"Missing required key tier"};
|
||||
return boost::system::error_code{129, error_missing_field_tier};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto tier = boost::json::try_value_to<int>(*jvtier);
|
||||
@@ -138,18 +122,14 @@ boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Emote must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvid = root.if_contains("id");
|
||||
if (jvid == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_id{
|
||||
"Missing required key id"};
|
||||
return boost::system::error_code{129, error_missing_field_id};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto id = boost::json::try_value_to<std::string>(*jvid);
|
||||
@@ -162,9 +142,7 @@ boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
const auto *jvemoteSetID = root.if_contains("emote_set_id");
|
||||
if (jvemoteSetID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_emoteSetID{"Missing required key emote_set_id"};
|
||||
return boost::system::error_code{129, error_missing_field_emoteSetID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto emoteSetID = boost::json::try_value_to<std::string>(*jvemoteSetID);
|
||||
@@ -177,9 +155,7 @@ boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
const auto *jvownerID = root.if_contains("owner_id");
|
||||
if (jvownerID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_ownerID{"Missing required key owner_id"};
|
||||
return boost::system::error_code{129, error_missing_field_ownerID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerID = boost::json::try_value_to<std::string>(*jvownerID);
|
||||
@@ -192,9 +168,7 @@ boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
const auto *jvformat = root.if_contains("format");
|
||||
if (jvformat == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_format{
|
||||
"Missing required key format"};
|
||||
return boost::system::error_code{129, error_missing_field_format};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
const auto format =
|
||||
boost::json::try_value_to<std::vector<std::string>>(*jvformat);
|
||||
@@ -216,18 +190,14 @@ boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Mention must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_userID{
|
||||
"Missing required key user_id"};
|
||||
return boost::system::error_code{129, error_missing_field_userID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
@@ -240,9 +210,7 @@ boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_userName{"Missing required key user_name"};
|
||||
return boost::system::error_code{129, error_missing_field_userName};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
@@ -255,9 +223,7 @@ boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_userLogin{"Missing required key user_login"};
|
||||
return boost::system::error_code{129, error_missing_field_userLogin};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
@@ -280,18 +246,14 @@ boost::json::result_for<MessageFragment, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"MessageFragment must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtype = root.if_contains("type");
|
||||
if (jvtype == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_type{
|
||||
"Missing required key type"};
|
||||
return boost::system::error_code{129, error_missing_field_type};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto type = boost::json::try_value_to<std::string>(*jvtype);
|
||||
@@ -304,9 +266,7 @@ boost::json::result_for<MessageFragment, boost::json::value>::type tag_invoke(
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_text{
|
||||
"Missing required key text"};
|
||||
return boost::system::error_code{129, error_missing_field_text};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
@@ -369,18 +329,14 @@ boost::json::result_for<Message, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Message must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_text{
|
||||
"Missing required key text"};
|
||||
return boost::system::error_code{129, error_missing_field_text};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
@@ -393,9 +349,7 @@ boost::json::result_for<Message, boost::json::value>::type tag_invoke(
|
||||
const auto *jvfragments = root.if_contains("fragments");
|
||||
if (jvfragments == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_fragments{"Missing required key fragments"};
|
||||
return boost::system::error_code{129, error_missing_field_fragments};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
const auto fragments =
|
||||
boost::json::try_value_to<std::vector<MessageFragment>>(*jvfragments);
|
||||
@@ -415,18 +369,14 @@ boost::json::result_for<Cheer, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Cheer must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbits = root.if_contains("bits");
|
||||
if (jvbits == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_bits{
|
||||
"Missing required key bits"};
|
||||
return boost::system::error_code{129, error_missing_field_bits};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto bits = boost::json::try_value_to<int>(*jvbits);
|
||||
@@ -446,20 +396,14 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Reply must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvparentMessageID = root.if_contains("parent_message_id");
|
||||
if (jvparentMessageID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_parentMessageID{
|
||||
"Missing required key parent_message_id"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_parentMessageID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto parentMessageID =
|
||||
@@ -473,10 +417,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvparentUserID = root.if_contains("parent_user_id");
|
||||
if (jvparentUserID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_parentUserID{
|
||||
"Missing required key parent_user_id"};
|
||||
return boost::system::error_code{129, error_missing_field_parentUserID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto parentUserID = boost::json::try_value_to<std::string>(*jvparentUserID);
|
||||
@@ -489,11 +430,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvparentUserLogin = root.if_contains("parent_user_login");
|
||||
if (jvparentUserLogin == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_parentUserLogin{
|
||||
"Missing required key parent_user_login"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_parentUserLogin};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto parentUserLogin =
|
||||
@@ -507,11 +444,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvparentUserName = root.if_contains("parent_user_name");
|
||||
if (jvparentUserName == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_parentUserName{
|
||||
"Missing required key parent_user_name"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_parentUserName};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto parentUserName =
|
||||
@@ -525,11 +458,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvparentMessageBody = root.if_contains("parent_message_body");
|
||||
if (jvparentMessageBody == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_parentMessageBody{
|
||||
"Missing required key parent_message_body"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_parentMessageBody};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto parentMessageBody =
|
||||
@@ -543,11 +472,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvthreadMessageID = root.if_contains("thread_message_id");
|
||||
if (jvthreadMessageID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_threadMessageID{
|
||||
"Missing required key thread_message_id"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_threadMessageID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto threadMessageID =
|
||||
@@ -561,10 +486,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvthreadUserID = root.if_contains("thread_user_id");
|
||||
if (jvthreadUserID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_threadUserID{
|
||||
"Missing required key thread_user_id"};
|
||||
return boost::system::error_code{129, error_missing_field_threadUserID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto threadUserID = boost::json::try_value_to<std::string>(*jvthreadUserID);
|
||||
@@ -577,11 +499,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvthreadUserLogin = root.if_contains("thread_user_login");
|
||||
if (jvthreadUserLogin == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_threadUserLogin{
|
||||
"Missing required key thread_user_login"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_threadUserLogin};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto threadUserLogin =
|
||||
@@ -595,11 +513,7 @@ boost::json::result_for<Reply, boost::json::value>::type tag_invoke(
|
||||
const auto *jvthreadUserName = root.if_contains("thread_user_name");
|
||||
if (jvthreadUserName == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_threadUserName{
|
||||
"Missing required key thread_user_name"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_threadUserName};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto threadUserName =
|
||||
@@ -628,20 +542,14 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Event must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbroadcasterUserID = root.if_contains("broadcaster_user_id");
|
||||
if (jvbroadcasterUserID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_broadcasterUserID{
|
||||
"Missing required key broadcaster_user_id"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_broadcasterUserID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserID =
|
||||
@@ -656,11 +564,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
root.if_contains("broadcaster_user_login");
|
||||
if (jvbroadcasterUserLogin == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_broadcasterUserLogin{
|
||||
"Missing required key broadcaster_user_login"};
|
||||
return boost::system::error_code{
|
||||
129, error_missing_field_broadcasterUserLogin};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserLogin =
|
||||
@@ -675,11 +579,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
root.if_contains("broadcaster_user_name");
|
||||
if (jvbroadcasterUserName == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_broadcasterUserName{
|
||||
"Missing required key broadcaster_user_name"};
|
||||
return boost::system::error_code{
|
||||
129, error_missing_field_broadcasterUserName};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserName =
|
||||
@@ -693,11 +593,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvchatterUserID = root.if_contains("chatter_user_id");
|
||||
if (jvchatterUserID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_chatterUserID{
|
||||
"Missing required key chatter_user_id"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_chatterUserID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto chatterUserID =
|
||||
@@ -711,11 +607,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvchatterUserLogin = root.if_contains("chatter_user_login");
|
||||
if (jvchatterUserLogin == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_chatterUserLogin{
|
||||
"Missing required key chatter_user_login"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_chatterUserLogin};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto chatterUserLogin =
|
||||
@@ -729,11 +621,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvchatterUserName = root.if_contains("chatter_user_name");
|
||||
if (jvchatterUserName == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_chatterUserName{
|
||||
"Missing required key chatter_user_name"};
|
||||
return boost::system::error_code{129,
|
||||
error_missing_field_chatterUserName};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto chatterUserName =
|
||||
@@ -747,9 +635,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvcolor = root.if_contains("color");
|
||||
if (jvcolor == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_color{
|
||||
"Missing required key color"};
|
||||
return boost::system::error_code{129, error_missing_field_color};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto color = boost::json::try_value_to<std::string>(*jvcolor);
|
||||
@@ -762,9 +648,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvbadges = root.if_contains("badges");
|
||||
if (jvbadges == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_badges{
|
||||
"Missing required key badges"};
|
||||
return boost::system::error_code{129, error_missing_field_badges};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
const auto badges =
|
||||
boost::json::try_value_to<std::vector<Badge>>(*jvbadges);
|
||||
@@ -776,9 +660,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvmessageID = root.if_contains("message_id");
|
||||
if (jvmessageID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_messageID{"Missing required key message_id"};
|
||||
return boost::system::error_code{129, error_missing_field_messageID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto messageID = boost::json::try_value_to<std::string>(*jvmessageID);
|
||||
@@ -791,10 +673,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvmessageType = root.if_contains("message_type");
|
||||
if (jvmessageType == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_messageType{
|
||||
"Missing required key message_type"};
|
||||
return boost::system::error_code{129, error_missing_field_messageType};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto messageType = boost::json::try_value_to<std::string>(*jvmessageType);
|
||||
@@ -807,9 +686,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
const auto *jvmessage = root.if_contains("message");
|
||||
if (jvmessage == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_message{"Missing required key message"};
|
||||
return boost::system::error_code{129, error_missing_field_message};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<Message>(*jvmessage);
|
||||
@@ -886,19 +763,14 @@ boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Payload must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsubscription = root.if_contains("subscription");
|
||||
if (jvsubscription == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_subscription{
|
||||
"Missing required key subscription"};
|
||||
return boost::system::error_code{129, error_missing_field_subscription};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto subscription =
|
||||
@@ -912,9 +784,7 @@ boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
const auto *jvevent = root.if_contains("event");
|
||||
if (jvevent == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_event{
|
||||
"Missing required key event"};
|
||||
return boost::system::error_code{129, error_missing_field_event};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto event = boost::json::try_value_to<Event>(*jvevent);
|
||||
|
||||
Reference in New Issue
Block a user