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
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 ()=default
 Constructs a QException object.
 ~QException () noexcept
 Destroys this QException object.
 QException (const QException &)=default
 Creates a copy of other.
QExceptionoperator= (const QException &)=default
 Copy-assigns other over this object.

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'
}
}

Inheriting from this class is not supported.

Definition at line 34 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 144 of file qexception.cpp.

◆ ~QUnhandledException()

QUnhandledException::~QUnhandledException ( )
overridenoexcept

Definition at line 194 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 153 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 161 of file qexception.cpp.

Member Function Documentation

◆ clone()

QUnhandledException * QUnhandledException::clone ( ) const
overridevirtual

Reimplemented from QException.

Definition at line 204 of file qexception.cpp.

◆ 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 189 of file qexception.cpp.

◆ 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 170 of file qexception.cpp.

◆ raise()

void QUnhandledException::raise ( ) const
overridevirtual

Reimplemented from QException.

Definition at line 198 of file qexception.cpp.

◆ swap()

void QUnhandledException::swap ( QUnhandledException & other)
inlinenoexcept
Since
6.0 \memberswap{unhandled exception object}

Definition at line 43 of file qexception.h.


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