refactor(eventsub): enforce static error categories (#5903)
This commit is contained in:
@@ -4,28 +4,24 @@ boost::json::result_for<{{struct.full_name}}, boost::json::value>::type tag_invo
|
||||
{% if struct.inner_root %}
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{"{{struct.full_name}} must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &outerRoot = jvRoot.get_object();
|
||||
|
||||
const auto *jvInnerRoot = outerRoot.if_contains("{{struct.inner_root}}");
|
||||
if (jvInnerRoot == nullptr)
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMissing{"{{struct.full_name}}'s key {{struct.inner_root}} is missing"};
|
||||
return boost::system::error_code{129, errorMissing};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::InnerRootMissing);
|
||||
}
|
||||
if (!jvInnerRoot->is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{"{{struct.full_name}}'s {{struct.inner_root}} must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvInnerRoot->get_object();
|
||||
{% else %}
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
static const error::ApplicationErrorCategory errorMustBeObject{"{{struct.full_name}} must be an object"};
|
||||
return boost::system::error_code{129, errorMustBeObject};
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user