aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppError.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-09-06 20:05:34 +0200
committerLinus Jahn <lnj@kaidan.im>2022-09-09 22:49:06 +0200
commitb113ae300efe5dc17f148a06df09062546bf54ee (patch)
treea7ada2bf208329687a7c4d47d74579551d9257a9 /src/base/QXmppError.cpp
parent74cc77670b009ef98d681477ac430210d02c4cc4 (diff)
downloadqxmpp-b113ae300efe5dc17f148a06df09062546bf54ee.tar.gz
Add QXmppError holding a description and std::any
Diffstat (limited to 'src/base/QXmppError.cpp')
-rw-r--r--src/base/QXmppError.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/base/QXmppError.cpp b/src/base/QXmppError.cpp
new file mode 100644
index 00000000..80578c0d
--- /dev/null
+++ b/src/base/QXmppError.cpp
@@ -0,0 +1,75 @@
+// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "QXmppError.h"
+
+#include "QXmppStanza.h"
+
+#include <QFileDevice>
+#include <QNetworkReply>
+
+///
+/// \class QXmppError
+///
+/// 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.
+///
+/// \since QXmpp 1.5
+///
+
+///
+/// \var QXmppError::description
+///
+/// Human readable description of the error.
+///
+
+///
+/// \var QXmppError::error
+///
+/// More specific details on the error. It may be of any type. Functions returning QXmppError
+/// should tell you which types are used.
+///
+
+///
+/// Returns whether the error is a QNetworkReply::NetworkError.
+///
+bool QXmppError::isFileError() const
+{
+ return holdsType<QFileDevice::FileError>();
+}
+
+///
+/// Returns whether the error is a QNetworkReply::NetworkError.
+///
+bool QXmppError::isNetworkError() const
+{
+ return holdsType<QNetworkReply::NetworkError>();
+}
+
+///
+/// Returns whether the error is a QXmppStanza::Error.
+///
+bool QXmppError::isStanzaError() const
+{
+ return holdsType<QXmppStanza::Error>();
+}
+
+///
+/// \fn QXmppError::holdsType()
+///
+/// Returns true if the error is of type T.
+///
+
+///
+/// \fn QXmppError::value()
+///
+/// Copies the value if it has type T, returns empty optional otherwise.
+///
+
+///
+/// \fn QXmppError::takeValue()
+///
+/// Moves out the value if it has type T, leaves the stored error intact and returns an empty
+/// optional otherwise.
+///