Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qexception.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QTCORE_QEXCEPTION_H
6#define QTCORE_QEXCEPTION_H
7
8#include <QtCore/qatomic.h>
9#include <QtCore/qshareddata.h>
10
11#ifndef QT_NO_EXCEPTIONS
12# include <exception>
13#endif
14
16
18
19
20#if !defined(QT_NO_EXCEPTIONS) || defined(Q_QDOC)
21
22class Q_CORE_EXPORT QException : public std::exception
23{
24public:
25 QException() = default;
26 ~QException() noexcept;
27 QException(const QException &) = default;
28 QException &operator=(const QException &) = default;
29 virtual void raise() const;
30 virtual QException *clone() const;
31};
32
34class Q_CORE_EXPORT QUnhandledException final : public QException
35{
36public:
37 QUnhandledException(std::exception_ptr exception = nullptr) noexcept;
38 ~QUnhandledException() noexcept override;
39
40 QUnhandledException(QUnhandledException &&other) noexcept;
41 QUnhandledException(const QUnhandledException &other) noexcept;
42
43 void swap(QUnhandledException &other) noexcept { d.swap(other.d); }
44
45 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUnhandledException)
46 QUnhandledException &operator=(const QUnhandledException &other) noexcept;
47
48 void raise() const override;
49 QUnhandledException *clone() const override;
50
51 std::exception_ptr exception() const;
52
53private:
54 QSharedDataPointer<QUnhandledExceptionPrivate> d;
55};
56
57namespace QtPrivate {
58
59class Q_CORE_EXPORT ExceptionStore
60{
61public:
62 void setException(const QException &e);
64 bool hasException() const;
67 Q_NORETURN void rethrowException() const;
69};
70
71} // namespace QtPrivate
72
73#else // QT_NO_EXCEPTIONS
74
75namespace QtPrivate {
76
77class Q_CORE_EXPORT ExceptionStore
78{
79public:
80 ExceptionStore() { }
81 inline void throwPossibleException() {}
82 inline void rethrowException() const { }
83};
84
85} // namespace QtPrivate
86
87#endif // QT_NO_EXCEPTIONS
88
89QT_END_NAMESPACE
90
91#endif
\inmodule QtCore
Definition qexception.h:23
QUnhandledExceptionPrivate(std::exception_ptr exception) noexcept
std::exception_ptr exceptionPtr
QFuture< void > future
[5]