Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
qx-error.h File Reference

The qx-error.h header file provides access to the Error interface.

#include "qx/core/qx_core_export.h"
#include <QHash>
#include <QMetaType>
#include <QTextStream>
#include "qx/core/qx-abstracterror.h"
Include dependency graph for qx-error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Qx::Error
 The Error class acts as an interface for an extensible variety of error objects. More...
 

Namespaces

namespace  Qx
 The Qx namespace is the main namespace through which all non-global functionality of the Qx library is accessed.
 

Concepts

concept  Qx::adapted_error
 Specifies that a non-error type has a registered error adapter.
 
concept  Qx::error_variant
 Specifies that a type is a Qx error variant.
 

Macros

#define QX_DECLARE_ERROR_ADAPTATION(Adaptable, Adapter)
 

Functions

QX_CORE_EXPORT QTextStream & operator<< (QTextStream &ts, const Qx::Error &e)
 

Macro Definition Documentation

◆ QX_DECLARE_ERROR_ADAPTATION

#define QX_DECLARE_ERROR_ADAPTATION ( Adaptable,
Adapter )
Value:
static_assert(Qx::error_adaptation<Adaptable, Adapter>, "Adapter must satisfy the 'error_adapter' concept " \
"and be constructable from Adaptable."); \
template<> \
struct QxErrorPrivate::adapter_registry<Adaptable> { typedef Adapter adapter; };
Specifies that two types form a Qx error adaptation.
Definition qx-abstracterror.h:145

This macro registers Adapter as an Error Adapter for the type Adaptable. Adaptable and Adapter together must satisfy the error_adaptation constraint.

Function Documentation

◆ operator<<()

QX_CORE_EXPORT QTextStream & operator<< ( QTextStream & ts,
const Qx::Error & e )

Writes the error e to the stream ts.

The error is written in a human-readable format, structured by its properties. A new line is always started after the error is written.

See also
postError().
ge.setValue(50);
ge.setCaption("Caption");
ge.setPrimary("Generic Error");
ge.setSecondary("There was an Error");
ge.setDetailed("- Issue 1\n- Issue2\n- Issue3");
QTextStream ts;
ts << Qx::Error(ge);
// Prints:
/*
* (WARNING) 0x00000032 Caption
* Generic Error
* There was an Error
*
* Details:
* --------
* - Issue 1
* - Issue 2
* - Issue 3
*/