5#include "qx/core/qx_core_export.h"
16namespace QxErrorPrivate
18 template<
class ErrorAdaptable>
19 struct adapter_registry;
45namespace QxErrorPrivate
49inline constexpr bool variant_has_error_types =
false;
51template <
typename... Types>
52inline constexpr bool variant_has_error_types<std::variant<Types...>> =
68 static inline const QString DETAILED_INFO_HEADING = u
"Details:\n--------"_s;
72 using AdapterType =
typename QxErrorPrivate::adapter_registry<K>::adapter;
76 static constexpr QLatin1StringView
TYPE_NAME{
"Error"};
81 QLatin1StringView mTypeName;
93 template<
class ErrorType>
112 template<
class EAble>
114 Error(
const EAble& adapted) :
Error(AdapterType<EAble>(adapted))
117 template<
typename Errors>
119 Error(
const Errors& e) :
Error(std::visit([](auto&& arg){
return arg; }, e))
124 quint16 typeCode()
const;
125 QLatin1StringView typeName()
const;
127 quint32 value()
const;
128 Severity severity()
const;
129 QString severityString(
bool uc =
true)
const;
130 QString caption()
const;
131 QString primary()
const;
132 QString secondary()
const;
133 QString details()
const;
135 bool isValid()
const;
136 bool equivalent(
const Error& other)
const;
137 quint64 code()
const;
138 QString hexCode()
const;
139 QString toString()
const;
141 Error& setSeverity(Severity sv);
142 Error withSeverity(Severity sv);
149 explicit operator bool()
const;
152friend QTextStream& ::operator<<(QTextStream& ts,
const Error& e);
164#define QX_DECLARE_ERROR_ADAPTATION(Adaptable, Adapter) \
165 static_assert(Qx::error_adaptation<Adaptable, Adapter>, "Adapter must satisfy the 'error_adapter' concept " \
166 "and be constructable from Adaptable."); \
168 struct QxErrorPrivate::adapter_registry<Adaptable> { typedef Adapter adapter; };
The Error class acts as an interface for an extensible variety of error objects.
Definition qx-error.h:65
Error(const EAble &adapted)
Definition qx-error.h:114
Error(const ErrorType &e)
Definition qx-error.h:95
static constexpr QLatin1StringView TYPE_NAME
Definition qx-error.h:76
bool operator==(const Error &other) const =default
bool operator!=(const Error &other) const =default
Error()
Definition qx-error.cpp:131
static constexpr quint16 TYPE_CODE
Definition qx-error.h:75
Error(const Errors &e)
Definition qx-error.h:119
IError defines the baseline inheritance interface for Qx error types.
Definition qx-abstracterror.h:28
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
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 a non-error type has a registered error adapter.
Definition qx-error.h:40
Specifies that two types form a Qx error adaptation.
Definition qx-abstracterror.h:145
Specifies that a type is a Qx error type.
Definition qx-abstracterror.h:122
Specifies that a type is a Qx error variant.
Definition qx-error.h:62
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
The qx-abstracterror.h header file provides access to the base class from which custom error types sh...
QX_CORE_EXPORT QTextStream & operator<<(QTextStream &ts, const Qx::Error &e)
Definition qx-error.cpp:396