![]() |
Qt 6.x
The Qt SDK
|
The QQmlError class encapsulates a QML error. More...
#include <qqmlerror.h>
Public Member Functions | |
QQmlError () | |
Creates an empty error object. | |
QQmlError (const QQmlError &) | |
Creates a copy of other. | |
QQmlError (QQmlError &&other) noexcept | |
QQmlError & | operator= (const QQmlError &) |
Assigns other to this error object. | |
~QQmlError () | |
void | swap (QQmlError &other) |
bool | isValid () const |
Returns true if this error is valid, otherwise false. | |
QUrl | url () const |
Returns the url for the file that caused this error. | |
void | setUrl (const QUrl &) |
Sets the url for the file that caused this error. | |
QString | description () const |
Returns the error description. | |
void | setDescription (const QString &) |
Sets the error description. | |
int | line () const |
Returns the error line number. | |
void | setLine (int) |
Sets the error line number. | |
int | column () const |
Returns the error column number. | |
void | setColumn (int) |
Sets the error column number. | |
QObject * | object () const |
Returns the nearest object where this error occurred. | |
void | setObject (QObject *) |
Sets the nearest object where this error occurred. | |
QtMsgType | messageType () const |
void | setMessageType (QtMsgType messageType) |
QString | toString () const |
Returns the error as a human readable string. | |
Friends | |
bool Q_QML_EXPORT | operator== (const QQmlError &a, const QQmlError &b) |
Related Symbols | |
(Note that these are not member symbols.) | |
QDebug | operator<< (QDebug debug, const QQmlError &error) |
Outputs a human readable version of error to debug. | |
The QQmlError class encapsulates a QML error.
QQmlError includes a textual description of the error, as well as location information (the file, line, and column). The toString() method creates a single-line, human-readable string containing all of this information, for example:
You can use qDebug(), qInfo(), or qWarning() to output errors to the console. This method will attempt to open the file indicated by the error and include additional contextual information.
Definition at line 17 of file qqmlerror.h.
QQmlError::QQmlError | ( | ) |
Creates an empty error object.
Definition at line 63 of file qqmlerror.cpp.
QQmlError::QQmlError | ( | const QQmlError & | other | ) |
Creates a copy of other.
Definition at line 71 of file qqmlerror.cpp.
References other().
|
inlinenoexcept |
Definition at line 22 of file qqmlerror.h.
QQmlError::~QQmlError | ( | ) |
Definition at line 101 of file qqmlerror.cpp.
int QQmlError::column | ( | ) | const |
Returns the error column number.
Definition at line 177 of file qqmlerror.cpp.
References QQmlErrorPrivate::column.
Referenced by setColumn(), and toString().
QString QQmlError::description | ( | ) | const |
Returns the error description.
Definition at line 137 of file qqmlerror.cpp.
References QQmlErrorPrivate::message.
Referenced by QQmlPluginImporter::importPlugins(), setDescription(), and toString().
bool QQmlError::isValid | ( | ) | const |
Returns true if this error is valid, otherwise false.
Definition at line 109 of file qqmlerror.cpp.
Referenced by QQmlPropertyCacheCreator< ObjectContainer >::buildMetaObjectsIncrementally(), QQmlTypeCompiler::compile(), and QQmlDelayedError::isValid().
int QQmlError::line | ( | ) | const |
Returns the error line number.
Definition at line 157 of file qqmlerror.cpp.
References QQmlErrorPrivate::line.
Referenced by setLine(), and toString().
QtMsgType QQmlError::messageType | ( | ) | const |
Returns the message type.
Definition at line 222 of file qqmlerror.cpp.
References QtWarningMsg, and QQmlErrorPrivate::type.
Referenced by setMessageType().
QObject * QQmlError::object | ( | ) | const |
Returns the nearest object where this error occurred.
Exceptions in bound property expressions set this to the object to which the property belongs. It will be 0 for all other exceptions.
Definition at line 200 of file qqmlerror.cpp.
References QQmlErrorPrivate::object.
Referenced by setObject().
Assigns other to this error object.
Definition at line 80 of file qqmlerror.cpp.
References QQmlErrorPrivate::column, QQmlErrorPrivate::line, QQmlErrorPrivate::message, QQmlErrorPrivate::object, other(), QQmlErrorPrivate::type, and QQmlErrorPrivate::url.
void QQmlError::setColumn | ( | int | column | ) |
Sets the error column number.
Definition at line 187 of file qqmlerror.cpp.
References QQmlErrorPrivate::column, and column().
Referenced by QQmlPropertyBindingJS::expressionChanged(), and QQmlDelayedError::setErrorLocation().
Sets the error description.
Definition at line 147 of file qqmlerror.cpp.
References description(), and QQmlErrorPrivate::message.
Referenced by QQmlPropertyBindingJS::expressionChanged(), QV4::generateWarning(), QQmlImportInstance::resolveType(), ListModel::set(), QQmlDelayedError::setErrorDescription(), and QQmlPropertyCacheCreator< ObjectContainer >::verifyNoICCycle().
void QQmlError::setLine | ( | int | line | ) |
Sets the error line number.
Definition at line 167 of file qqmlerror.cpp.
References QQmlErrorPrivate::line, and line().
Referenced by QQmlPropertyBindingJS::expressionChanged(), QV4::generateWarning(), and QQmlDelayedError::setErrorLocation().
Sets the messageType for this message. The message type determines which QDebug handlers are responsible for receiving the message.
Definition at line 235 of file qqmlerror.cpp.
References messageType(), and QQmlErrorPrivate::type.
Sets the nearest object where this error occurred.
Definition at line 210 of file qqmlerror.cpp.
References QQmlErrorPrivate::object, and object().
Referenced by QQmlPropertyBindingJS::expressionChanged(), and QQmlDelayedError::setErrorObject().
Sets the url for the file that caused this error.
Definition at line 127 of file qqmlerror.cpp.
References QQmlErrorPrivate::url, and url().
Referenced by QQmlPropertyBindingJS::expressionChanged(), QV4::generateWarning(), QQmlDataBlob::setError(), and QQmlDelayedError::setErrorLocation().
Definition at line 30 of file qqmlerror.h.
References d, other(), and qt_ptr_swap().
QString QQmlError::toString | ( | ) | const |
Returns the error as a human readable string.
Definition at line 245 of file qqmlerror.cpp.
References column(), description(), QUrl::isEmpty(), QString::isEmpty(), QUrl::isLocalFile(), line(), QString::number(), QUrl::path(), QUrl::toString(), and url().
Referenced by QQmlDataBlob::setError().
QUrl QQmlError::url | ( | ) | const |
Returns the url for the file that caused this error.
Definition at line 117 of file qqmlerror.cpp.
References QQmlErrorPrivate::url.
Referenced by setUrl(), and toString().
Outputs a human readable version of error to debug.
Definition at line 282 of file qqmlerror.cpp.
References QByteArray::append(), QString::at(), ch, QByteArray::constData(), debug, error, file, i, line, qMax(), qMin(), qPrintable, QIODeviceBase::ReadOnly, QByteArray::reserve(), QUrl::scheme(), QString::size(), QString::split(), QString::toLocal8Bit(), url, and QQmlFile::urlToLocalFileOrQrc().
Definition at line 270 of file qqmlerror.cpp.