Move to impl namespace
Some checks failed
PR Check / on-push-commit-check (push) Failing after 1m45s
Some checks failed
PR Check / on-push-commit-check (push) Failing after 1m45s
This commit is contained in:
parent
cda854553c
commit
c5ad3720de
2 changed files with 81 additions and 80 deletions
|
@ -58,19 +58,17 @@ struct Type : TypeVariant {
|
|||
};
|
||||
|
||||
struct StanzaErrorBase : std::exception {};
|
||||
|
||||
// DO NOT MOVE TO ANOTHER NAMESPACE(where no heirs). VIA friend A FUNCTION IS ADDED THAT VIA ADL WILL BE SEARCHED FOR HEIRS
|
||||
// C++20 modules very unstable in clangd :(
|
||||
namespace impl {
|
||||
template <typename T, typename Default>
|
||||
struct StanzaErrorImpl : StanzaErrorBase {
|
||||
struct StanzaError : StanzaErrorBase {
|
||||
static constexpr auto kDefaultName = "error";
|
||||
static constexpr auto kDefaultNamespace = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
||||
static inline const auto kKebabCaseName = static_cast<std::string>(utils::ToKebabCaseName<T>());
|
||||
constexpr StanzaErrorImpl(std::optional<std::string> by, Type type) : by(std::move(by)), type(std::move(type)) {
|
||||
constexpr StanzaError(std::optional<std::string> by, Type type) : by(std::move(by)), type(std::move(type)) {
|
||||
}
|
||||
constexpr StanzaErrorImpl() = default;
|
||||
constexpr StanzaError() = default;
|
||||
struct FieldInfo {
|
||||
using Main = StanzaErrorImpl;
|
||||
using Main = StanzaError;
|
||||
using Info = serialization::MetaInfo<Main>;
|
||||
using Type = Type;
|
||||
static inline const std::string kName = "type";
|
||||
|
@ -121,7 +119,7 @@ struct StanzaErrorImpl : StanzaErrorBase {
|
|||
auto node = element->add_child_element(kKebabCaseName);
|
||||
node->set_namespace_declaration(kDefaultNamespace);
|
||||
}
|
||||
constexpr auto operator==(const StanzaErrorImpl&) const -> bool {
|
||||
constexpr auto operator==(const StanzaError&) const -> bool {
|
||||
return true;
|
||||
};
|
||||
[[nodiscard]] constexpr auto what() const noexcept -> const char* override {
|
||||
|
@ -129,6 +127,8 @@ struct StanzaErrorImpl : StanzaErrorBase {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
||||
// Helper class to prevent parsing response stream into an expected return type if its name is an 'error'
|
||||
struct UnknownStanzaError : StanzaErrorBase {
|
||||
static constexpr auto kDefaultName = "stream:error";
|
||||
|
@ -151,71 +151,71 @@ struct UnknownStanzaError : StanzaErrorBase {
|
|||
}
|
||||
};
|
||||
|
||||
struct BadRequest : StanzaErrorImpl<BadRequest, type::Modify> {
|
||||
using StanzaErrorImpl<BadRequest, type::Modify>::StanzaErrorImpl;
|
||||
struct BadRequest : impl::StanzaError<BadRequest, type::Modify> {
|
||||
using impl::StanzaError<BadRequest, type::Modify>::StanzaError;
|
||||
};
|
||||
struct Conflict : StanzaErrorImpl<Conflict, type::Cancel> {
|
||||
using StanzaErrorImpl<Conflict, type::Cancel>::StanzaErrorImpl;
|
||||
struct Conflict : impl::StanzaError<Conflict, type::Cancel> {
|
||||
using impl::StanzaError<Conflict, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct FeatureNotImplemented : StanzaErrorImpl<FeatureNotImplemented, type::Cancel> {
|
||||
using StanzaErrorImpl<FeatureNotImplemented, type::Cancel>::StanzaErrorImpl;
|
||||
struct FeatureNotImplemented : impl::StanzaError<FeatureNotImplemented, type::Cancel> {
|
||||
using impl::StanzaError<FeatureNotImplemented, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct Forbidden : StanzaErrorImpl<Forbidden, type::Auth> {
|
||||
using StanzaErrorImpl<Forbidden, type::Auth>::StanzaErrorImpl;
|
||||
struct Forbidden : impl::StanzaError<Forbidden, type::Auth> {
|
||||
using impl::StanzaError<Forbidden, type::Auth>::StanzaError;
|
||||
};
|
||||
struct Gone : StanzaErrorImpl<Gone, type::Cancel> {
|
||||
using StanzaErrorImpl<Gone, type::Cancel>::StanzaErrorImpl;
|
||||
struct Gone : impl::StanzaError<Gone, type::Cancel> {
|
||||
using impl::StanzaError<Gone, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct InternalServerError : StanzaErrorImpl<InternalServerError, type::Cancel> {
|
||||
using StanzaErrorImpl<InternalServerError, type::Cancel>::StanzaErrorImpl;
|
||||
struct InternalServerError : impl::StanzaError<InternalServerError, type::Cancel> {
|
||||
using impl::StanzaError<InternalServerError, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct ItemNotFound : StanzaErrorImpl<ItemNotFound, type::Cancel> {
|
||||
using StanzaErrorImpl<ItemNotFound, type::Cancel>::StanzaErrorImpl;
|
||||
struct ItemNotFound : impl::StanzaError<ItemNotFound, type::Cancel> {
|
||||
using impl::StanzaError<ItemNotFound, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct JidMalformed : StanzaErrorImpl<JidMalformed, type::Modify> {
|
||||
using StanzaErrorImpl<JidMalformed, type::Modify>::StanzaErrorImpl;
|
||||
struct JidMalformed : impl::StanzaError<JidMalformed, type::Modify> {
|
||||
using impl::StanzaError<JidMalformed, type::Modify>::StanzaError;
|
||||
};
|
||||
struct NotAcceptable : StanzaErrorImpl<NotAcceptable, type::Modify> {
|
||||
using StanzaErrorImpl<NotAcceptable, type::Modify>::StanzaErrorImpl;
|
||||
struct NotAcceptable : impl::StanzaError<NotAcceptable, type::Modify> {
|
||||
using impl::StanzaError<NotAcceptable, type::Modify>::StanzaError;
|
||||
};
|
||||
struct NotAllowed : StanzaErrorImpl<NotAllowed, type::Cancel> {
|
||||
using StanzaErrorImpl<NotAllowed, type::Cancel>::StanzaErrorImpl;
|
||||
struct NotAllowed : impl::StanzaError<NotAllowed, type::Cancel> {
|
||||
using impl::StanzaError<NotAllowed, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct NotAuthorized : StanzaErrorImpl<NotAuthorized, type::Auth> {
|
||||
using StanzaErrorImpl<NotAuthorized, type::Auth>::StanzaErrorImpl;
|
||||
struct NotAuthorized : impl::StanzaError<NotAuthorized, type::Auth> {
|
||||
using impl::StanzaError<NotAuthorized, type::Auth>::StanzaError;
|
||||
};
|
||||
struct PolicyViolation : StanzaErrorImpl<PolicyViolation, type::Modify> {
|
||||
using StanzaErrorImpl<PolicyViolation, type::Modify>::StanzaErrorImpl;
|
||||
struct PolicyViolation : impl::StanzaError<PolicyViolation, type::Modify> {
|
||||
using impl::StanzaError<PolicyViolation, type::Modify>::StanzaError;
|
||||
};
|
||||
struct RecipientUnavailable : StanzaErrorImpl<RecipientUnavailable, type::Wait> {
|
||||
using StanzaErrorImpl<RecipientUnavailable, type::Wait>::StanzaErrorImpl;
|
||||
struct RecipientUnavailable : impl::StanzaError<RecipientUnavailable, type::Wait> {
|
||||
using impl::StanzaError<RecipientUnavailable, type::Wait>::StanzaError;
|
||||
};
|
||||
struct Redirect : StanzaErrorImpl<Redirect, type::Modify> {
|
||||
using StanzaErrorImpl<Redirect, type::Modify>::StanzaErrorImpl;
|
||||
struct Redirect : impl::StanzaError<Redirect, type::Modify> {
|
||||
using impl::StanzaError<Redirect, type::Modify>::StanzaError;
|
||||
};
|
||||
struct RegistrationRequired : StanzaErrorImpl<RegistrationRequired, type::Auth> {
|
||||
using StanzaErrorImpl<RegistrationRequired, type::Auth>::StanzaErrorImpl;
|
||||
struct RegistrationRequired : impl::StanzaError<RegistrationRequired, type::Auth> {
|
||||
using impl::StanzaError<RegistrationRequired, type::Auth>::StanzaError;
|
||||
};
|
||||
struct RemoteServerNotFound : StanzaErrorImpl<RemoteServerNotFound, type::Cancel> {
|
||||
using StanzaErrorImpl<RemoteServerNotFound, type::Cancel>::StanzaErrorImpl;
|
||||
struct RemoteServerNotFound : impl::StanzaError<RemoteServerNotFound, type::Cancel> {
|
||||
using impl::StanzaError<RemoteServerNotFound, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct RemoteServerTimeout : StanzaErrorImpl<RemoteServerTimeout, type::Wait> {
|
||||
using StanzaErrorImpl<RemoteServerTimeout, type::Wait>::StanzaErrorImpl;
|
||||
struct RemoteServerTimeout : impl::StanzaError<RemoteServerTimeout, type::Wait> {
|
||||
using impl::StanzaError<RemoteServerTimeout, type::Wait>::StanzaError;
|
||||
};
|
||||
struct ResourceConstraint : StanzaErrorImpl<ResourceConstraint, type::Wait> {
|
||||
using StanzaErrorImpl<ResourceConstraint, type::Wait>::StanzaErrorImpl;
|
||||
struct ResourceConstraint : impl::StanzaError<ResourceConstraint, type::Wait> {
|
||||
using impl::StanzaError<ResourceConstraint, type::Wait>::StanzaError;
|
||||
};
|
||||
struct ServiceUnavailable : StanzaErrorImpl<ServiceUnavailable, type::Cancel> {
|
||||
using StanzaErrorImpl<ServiceUnavailable, type::Cancel>::StanzaErrorImpl;
|
||||
struct ServiceUnavailable : impl::StanzaError<ServiceUnavailable, type::Cancel> {
|
||||
using impl::StanzaError<ServiceUnavailable, type::Cancel>::StanzaError;
|
||||
};
|
||||
struct SubscriptionRequired : StanzaErrorImpl<SubscriptionRequired, type::Auth> {
|
||||
using StanzaErrorImpl<SubscriptionRequired, type::Auth>::StanzaErrorImpl;
|
||||
struct SubscriptionRequired : impl::StanzaError<SubscriptionRequired, type::Auth> {
|
||||
using impl::StanzaError<SubscriptionRequired, type::Auth>::StanzaError;
|
||||
};
|
||||
struct UndefinedCondition : StanzaErrorImpl<UndefinedCondition, type::Modify> {
|
||||
using StanzaErrorImpl<UndefinedCondition, type::Modify>::StanzaErrorImpl;
|
||||
struct UndefinedCondition : impl::StanzaError<UndefinedCondition, type::Modify> {
|
||||
using impl::StanzaError<UndefinedCondition, type::Modify>::StanzaError;
|
||||
};
|
||||
struct UnexpectedRequest : StanzaErrorImpl<UnexpectedRequest, type::Modify> {
|
||||
using StanzaErrorImpl<UnexpectedRequest, type::Modify>::StanzaErrorImpl;
|
||||
struct UnexpectedRequest : impl::StanzaError<UnexpectedRequest, type::Modify> {
|
||||
using impl::StanzaError<UnexpectedRequest, type::Modify>::StanzaError;
|
||||
};
|
||||
|
||||
using StanzaError = std::variant<BadRequest,
|
||||
|
|
|
@ -10,10 +10,9 @@ namespace error::stream {
|
|||
|
||||
struct BaseError : std::exception {};
|
||||
|
||||
// DO NOT MOVE TO ANOTHER NAMESPACE(where no heirs). VIA friend A FUNCTION IS ADDED THAT VIA ADL WILL BE SEARCHED FOR HEIRS
|
||||
// C++20 modules very unstable in clangd :(
|
||||
namespace impl {
|
||||
template <typename T>
|
||||
struct ErrorImpl : BaseError {
|
||||
struct Error : BaseError {
|
||||
static constexpr auto kDefaultName = "stream:error";
|
||||
static inline const auto kKebabCaseName = static_cast<std::string>(utils::ToKebabCaseName<T>());
|
||||
|
||||
|
@ -40,6 +39,8 @@ struct ErrorImpl : BaseError {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
||||
// Helper class to prevent parsing response stream into an expected return type if its name is a 'stream:error'
|
||||
struct UnknownXmppError : BaseError {
|
||||
static constexpr auto kDefaultName = "stream:error";
|
||||
|
@ -59,31 +60,31 @@ struct UnknownXmppError : BaseError {
|
|||
}
|
||||
};
|
||||
|
||||
struct BadFormat : ErrorImpl<BadFormat> {};
|
||||
struct BadNamespacePrefix : ErrorImpl<BadNamespacePrefix> {};
|
||||
struct Conflict : ErrorImpl<Conflict> {};
|
||||
struct ConnectionTimeout : ErrorImpl<ConnectionTimeout> {};
|
||||
struct HostGone : ErrorImpl<HostGone> {};
|
||||
struct HostUnknown : ErrorImpl<HostUnknown> {};
|
||||
struct ImproperAdressing : ErrorImpl<ImproperAdressing> {};
|
||||
struct InternalServerError : ErrorImpl<InternalServerError> {};
|
||||
struct InvalidFrom : ErrorImpl<InvalidFrom> {};
|
||||
struct InvalidNamespace : ErrorImpl<InvalidNamespace> {};
|
||||
struct InvalidXml : ErrorImpl<InvalidXml> {};
|
||||
struct NotAuthorized : ErrorImpl<NotAuthorized> {};
|
||||
struct NotWellFormed : ErrorImpl<NotWellFormed> {};
|
||||
struct PolicyViolation : ErrorImpl<PolicyViolation> {};
|
||||
struct RemoteConnectionFailed : ErrorImpl<RemoteConnectionFailed> {};
|
||||
struct Reset : ErrorImpl<Reset> {};
|
||||
struct ResourceConstraint : ErrorImpl<ResourceConstraint> {};
|
||||
struct RestrictedXml : ErrorImpl<RestrictedXml> {};
|
||||
struct SeeOtherHost : ErrorImpl<SeeOtherHost> {};
|
||||
struct SystemShutdown : ErrorImpl<SystemShutdown> {};
|
||||
struct UndefinedCondition : ErrorImpl<UndefinedCondition> {};
|
||||
struct UnsupportedEncoding : ErrorImpl<UnsupportedEncoding> {};
|
||||
struct UnsupportedFeature : ErrorImpl<UnsupportedFeature> {};
|
||||
struct UnsupportedStanzaType : ErrorImpl<UnsupportedStanzaType> {};
|
||||
struct UnsupportedVersion : ErrorImpl<UnsupportedVersion> {};
|
||||
struct BadFormat : impl::Error<BadFormat> {};
|
||||
struct BadNamespacePrefix : impl::Error<BadNamespacePrefix> {};
|
||||
struct Conflict : impl::Error<Conflict> {};
|
||||
struct ConnectionTimeout : impl::Error<ConnectionTimeout> {};
|
||||
struct HostGone : impl::Error<HostGone> {};
|
||||
struct HostUnknown : impl::Error<HostUnknown> {};
|
||||
struct ImproperAdressing : impl::Error<ImproperAdressing> {};
|
||||
struct InternalServerError : impl::Error<InternalServerError> {};
|
||||
struct InvalidFrom : impl::Error<InvalidFrom> {};
|
||||
struct InvalidNamespace : impl::Error<InvalidNamespace> {};
|
||||
struct InvalidXml : impl::Error<InvalidXml> {};
|
||||
struct NotAuthorized : impl::Error<NotAuthorized> {};
|
||||
struct NotWellFormed : impl::Error<NotWellFormed> {};
|
||||
struct PolicyViolation : impl::Error<PolicyViolation> {};
|
||||
struct RemoteConnectionFailed : impl::Error<RemoteConnectionFailed> {};
|
||||
struct Reset : impl::Error<Reset> {};
|
||||
struct ResourceConstraint : impl::Error<ResourceConstraint> {};
|
||||
struct RestrictedXml : impl::Error<RestrictedXml> {};
|
||||
struct SeeOtherHost : impl::Error<SeeOtherHost> {};
|
||||
struct SystemShutdown : impl::Error<SystemShutdown> {};
|
||||
struct UndefinedCondition : impl::Error<UndefinedCondition> {};
|
||||
struct UnsupportedEncoding : impl::Error<UnsupportedEncoding> {};
|
||||
struct UnsupportedFeature : impl::Error<UnsupportedFeature> {};
|
||||
struct UnsupportedStanzaType : impl::Error<UnsupportedStanzaType> {};
|
||||
struct UnsupportedVersion : impl::Error<UnsupportedVersion> {};
|
||||
|
||||
} // namespace error::stream
|
||||
|
||||
|
|
Loading…
Reference in a new issue