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/subscription.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
@@ -12,18 +12,14 @@ boost::json::result_for<Transport, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Transport 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 *jvmethod = root.if_contains("method");
|
||||
if (jvmethod == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_method{
|
||||
"Missing required key method"};
|
||||
return boost::system::error_code{129, error_missing_field_method};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto method = boost::json::try_value_to<std::string>(*jvmethod);
|
||||
@@ -36,9 +32,7 @@ boost::json::result_for<Transport, boost::json::value>::type tag_invoke(
|
||||
const auto *jvsessionID = root.if_contains("session_id");
|
||||
if (jvsessionID == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_sessionID{"Missing required key session_id"};
|
||||
return boost::system::error_code{129, error_missing_field_sessionID};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto sessionID = boost::json::try_value_to<std::string>(*jvsessionID);
|
||||
@@ -60,18 +54,14 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{
|
||||
"Subscription 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);
|
||||
@@ -84,9 +74,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
const auto *jvstatus = root.if_contains("status");
|
||||
if (jvstatus == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_status{
|
||||
"Missing required key status"};
|
||||
return boost::system::error_code{129, error_missing_field_status};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto status = boost::json::try_value_to<std::string>(*jvstatus);
|
||||
@@ -99,9 +87,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
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);
|
||||
@@ -114,9 +100,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
const auto *jvversion = root.if_contains("version");
|
||||
if (jvversion == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_version{"Missing required key version"};
|
||||
return boost::system::error_code{129, error_missing_field_version};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto version = boost::json::try_value_to<std::string>(*jvversion);
|
||||
@@ -129,9 +113,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
const auto *jvtransport = root.if_contains("transport");
|
||||
if (jvtransport == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_transport{"Missing required key transport"};
|
||||
return boost::system::error_code{129, error_missing_field_transport};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto transport = boost::json::try_value_to<Transport>(*jvtransport);
|
||||
@@ -144,9 +126,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
const auto *jvcreatedAt = root.if_contains("created_at");
|
||||
if (jvcreatedAt == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory
|
||||
error_missing_field_createdAt{"Missing required key created_at"};
|
||||
return boost::system::error_code{129, error_missing_field_createdAt};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto createdAt = boost::json::try_value_to<std::string>(*jvcreatedAt);
|
||||
@@ -159,9 +139,7 @@ boost::json::result_for<Subscription, boost::json::value>::type tag_invoke(
|
||||
const auto *jvcost = root.if_contains("cost");
|
||||
if (jvcost == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory error_missing_field_cost{
|
||||
"Missing required key cost"};
|
||||
return boost::system::error_code{129, error_missing_field_cost};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto cost = boost::json::try_value_to<int>(*jvcost);
|
||||
|
||||
Reference in New Issue
Block a user