1#ifndef QX_ABSTRACTERROR_H
2#define QX_ABSTRACTERROR_H
5#include "qx/core/qx_core_export.h"
17#include "qx/core/qx-global.h"
20#include "qx/utility/qx-stringliteral.h"
22using namespace Qt::Literals::StringLiterals;
32 static inline const QString T_CODE_DUPE = u
"Error type code %1 is already claimed by %2!"_s;
33 static inline const QString T_NAME_DUPE = u
"Error type name %1 is already claimed!"_s;
34 static inline const QString T_CODE_RESERVED = u
"Error type code %1 is reserved!"_s;
35 static inline constinit QHash<quint16, const QString*> codeRegistry;
36 static constexpr std::array<QStringView, 10> RESERVED_NAMES{
41 u
"Qx::DownloadManagerReport",
42 u
"Qx::DownloadOpReport",
46 u
"Qx::SqlSchemaReport",
52 static QSet<QString>& nameRegistry();
56 static bool registerType(quint16 tc,
const QString& tn);
86template<CStringLiteral EName, qu
int16 ECode>
87class AbstractError :
protected IError
93 static constexpr QLatin1StringView
TYPE_NAME{EName};
96 static const bool REGISTER;
104 using IError::registerType;
134template<CStringLiteral EName, qu
int16 ECode>
135const bool AbstractError<EName, ECode>::REGISTER = registerType(TYPE_CODE, TYPE_NAME);
141 !std::move_constructible<A> &&
142 !std::copy_constructible<A>;
144template<
class Able,
class Ater>
150#define QX_ERROR_TYPE(Type, Name, Code) \
151 Type final : public Qx::AbstractError<Name, Code>
The AbstractError template class completes the Error interface and acts as the base class from which ...
Definition qx-abstracterror.h:88
static constexpr QLatin1StringView TYPE_NAME
Definition qx-abstracterror.h:93
bool operator==(const AbstractError &other) const =default
static constexpr quint16 TYPE_CODE
Definition qx-abstracterror.h:92
bool operator!=(const AbstractError &other) const =default
bool operator!=(const IError &other) const =default
virtual QString deriveCaption() const
Definition qx-abstracterror.cpp:102
virtual quint32 deriveValue() const
Definition qx-abstracterror.cpp:78
virtual QString deriveSecondary() const
Definition qx-abstracterror.cpp:124
bool operator==(const IError &other) const =default
virtual QString derivePrimary() const
Definition qx-abstracterror.cpp:113
virtual Severity deriveSeverity() const
Definition qx-abstracterror.cpp:87
virtual QString deriveDetails() const
Definition qx-abstracterror.cpp:135
Specifies that two types form a Qx error adaptation.
Definition qx-abstracterror.h:145
Specifies that a type is a Qx error adapter.
Definition qx-abstracterror.h:139
Specifies that a type is a Qx error type.
Definition qx-abstracterror.h:122
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-abstracterror.cpp:13
Severity
Definition qx-global.h:11
CStringLiteral acts like a typedef/alias for a StringLiteral that uses char as its storage type.
Definition qx-stringliteral.h:194