Qt 6.x
The Qt SDK
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
 
virtual void raise () const
 In your QException subclass, reimplement raise() like this:
 
virtual QExceptionclone () const
 In your QException subclass, reimplement clone() like this:
 

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'
}
}
\inmodule QtCore
Definition qexception.h:31
double e
auto run(QThreadPool *pool, Function &&f, Args &&...args)
GLfloat GLfloat f

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.

◆ ~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.

◆ 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.

References e.

◆ 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: