Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QUnhandledException Class Referencefinal

\inmodule QtCore More...

#include <qexception.h>

+ Inheritance diagram for QUnhandledException:
+ Collaboration diagram for QUnhandledException:

Public Member Functions

 QUnhandledException (std::exception_ptr exception=nullptr) noexcept
 
 ~QUnhandledException () noexcept override
 
 QUnhandledException (QUnhandledException &&other) noexcept
 Move-constructs a QUnhandledException, making it point to the same object as other was pointing to.
 
 QUnhandledException (const QUnhandledException &other) noexcept
 Constructs a QUnhandledException object as a copy of other.
 
void swap (QUnhandledException &other) noexcept
 
QUnhandledExceptionoperator= (const QUnhandledException &other) noexcept
 Assigns other to this QUnhandledException object and returns a reference to this QUnhandledException object.
 
void raise () const override
 
QUnhandledExceptionclone () const override
 
std::exception_ptr exception () const
 
- Public Member Functions inherited from QException
 ~QException () noexcept
 

Detailed Description

\inmodule QtCore

The QUnhandledException class represents an unhandled exception in a Qt Concurrent worker thread.

Since
5.0

If a worker thread throws an exception that is not a subclass of QException, the \l{Qt Concurrent} functions will throw a QUnhandledException on the receiver thread side. The information about the actual exception that has been thrown will be saved in the QUnhandledException class and can be obtained using the exception() method. For example, you can process the exception held by QUnhandledException in the following way:

try {
auto f = QtConcurrent::run([] { throw MyException {}; });
// ...
} catch (const QUnhandledException &e) {
try {
if (e.exception())
std::rethrow_exception(e.exception());
} catch (const MyException &ex) {
// Process 'ex'
}
}
void raise() const override
[1]
MyException * clone() const override
[2]
\inmodule QtCore
Definition qexception.h:22
\inmodule QtCore
Definition qexception.h:31
std::exception_ptr exception() const
QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, Function &&f, Args &&...args)

Inheriting from this class is not supported.

Definition at line 30 of file qexception.h.

Constructor & Destructor Documentation

◆ QUnhandledException() [1/3]

QUnhandledException::QUnhandledException ( std::exception_ptr exception = nullptr)
noexcept
Since
6.0

Constructs a new QUnhandledException object. Saves the pointer to the actual exception object if exception is passed.

See also
exception()

Definition at line 116 of file qexception.cpp.

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~QUnhandledException()

QUnhandledException::~QUnhandledException ( )
overridenoexcept

Definition at line 168 of file qexception.cpp.

◆ QUnhandledException() [2/3]

QUnhandledException::QUnhandledException ( QUnhandledException && other)
noexcept

Move-constructs a QUnhandledException, making it point to the same object as other was pointing to.

Definition at line 125 of file qexception.cpp.

◆ QUnhandledException() [3/3]

QUnhandledException::QUnhandledException ( const QUnhandledException & other)
noexcept

Constructs a QUnhandledException object as a copy of other.

Definition at line 133 of file qexception.cpp.

Member Function Documentation

◆ clone()

QUnhandledException * QUnhandledException::clone ( ) const
overridevirtual

Reimplemented from QException.

Definition at line 178 of file qexception.cpp.

References QUnhandledException().

+ Here is the call graph for this function:

◆ exception()

std::exception_ptr QUnhandledException::exception ( ) const
Since
6.0

Returns a \l{https://en.cppreference.com/w/cpp/error/exception_ptr}{pointer} to the actual exception that has been saved in this QUnhandledException. Returns a null pointer, if it does not point to an exception object.

Definition at line 163 of file qexception.cpp.

References QUnhandledExceptionPrivate::exceptionPtr.

◆ operator=()

QUnhandledException & QUnhandledException::operator= ( const QUnhandledException & other)
noexcept

Assigns other to this QUnhandledException object and returns a reference to this QUnhandledException object.

Definition at line 142 of file qexception.cpp.

References d, and other().

+ Here is the call graph for this function:

◆ raise()

void QUnhandledException::raise ( ) const
overridevirtual

Reimplemented from QException.

Definition at line 172 of file qexception.cpp.

◆ swap()

void QUnhandledException::swap ( QUnhandledException & other)
inlinenoexcept
Since
6.0

Swaps this QUnhandledException with other. This function is very fast and never fails.

Definition at line 39 of file qexception.h.

References d, and other().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: