QXmppError Struct

The QXmppError struct describes an error with a human-readable description and an optional typed error value. More...

Header: #include <QXmppError.h>
Since: QXmpp 1.5

Public Functions

bool holdsType() const
bool isFileError() const
bool isNetworkError() const
bool isStanzaError() const
std::optional<T> takeValue()
std::optional<T> value() const

Public Variables

QString description
std::any error

Static Public Members

QXmppError fromFileDevice(const QFileDevice &file)
QXmppError fromIoDevice(const QIODevice &device)
QXmppError fromNetworkReply(const QNetworkReply &reply)

Detailed Description

Generic error class holding a description and a more specific error object. The specific error usually is something like a QXmppStanza::Error or an enum.

Member Function Documentation

[static] QXmppError QXmppError::fromFileDevice(const QFileDevice &file)

Constructs a QXmppError from a QFileDevice

It creates a QXmppError with the error string and a QFileDevice::FileError.

file.

[static] QXmppError QXmppError::fromIoDevice(const QIODevice &device)

Constructs a QXmppError from an QIODevice

It tries to cast the IO device to different known IO devices to get a useful more specific error, i.e. it returns a QXmppError with QFileDevice::FileError for QFileDevices.

device.

[static] QXmppError QXmppError::fromNetworkReply(const QNetworkReply &reply)

Constructs a QXmppError from a QNetworkReply

It creates a QXmppError with the error string and network error from the reply.

reply.

template <typename T> bool QXmppError::holdsType() const

Returns true if the error is of type T.

bool QXmppError::isFileError() const

Returns whether the error is a QNetworkReply::NetworkError.

bool QXmppError::isNetworkError() const

Returns whether the error is a QNetworkReply::NetworkError.

bool QXmppError::isStanzaError() const

Returns whether the error is a QXmppStanza::Error.

template <typename T> std::optional<T> QXmppError::takeValue()

Moves out the value if it has type T, leaves the stored error intact and returns an empty optional otherwise.

template <typename T> std::optional<T> QXmppError::value() const

Copies the value if it has type T, returns empty optional otherwise.

Member Variable Documentation

QString QXmppError::description

Human readable description of the error.

std::any QXmppError::error

More specific details on the error. It may be of any type. Functions returning QXmppError should tell you which types are used.

device.