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>.
|
Represents an error message connected to the dom. More...
#include <qqmldomerrormessage_p.h>
Public Types | |
using | Level = ErrorLevel |
Public Member Functions | |
ErrorMessage (const QString &message, const ErrorGroups &errorGroups, Level level=Level::Warning, const Path &path=Path(), const QString &file=QString(), SourceLocation location=SourceLocation(), QLatin1String errorId=QLatin1String("")) | |
ErrorMessage (const ErrorGroups &errorGroups, const DiagnosticMessage &msg, const Path &path=Path(), const QString &file=QString(), QLatin1String errorId=QLatin1String("")) | |
ErrorMessage & | withErrorId (QLatin1String errorId) |
ErrorMessage & | withPath (const Path &) |
ErrorMessage & | withFile (const QString &) |
ErrorMessage & | withFile (QStringView) |
ErrorMessage & | withLocation (SourceLocation) |
ErrorMessage & | withItem (const DomItem &) |
ErrorMessage | handle (const ErrorHandler &errorHandler=nullptr) |
void | dump (const Sink &s) const |
QString | toString () const |
QCborMap | toCbor () const |
Static Public Member Functions | |
static QLatin1String | msg (const char *errorId, ErrorMessage &&err) |
static QLatin1String | msg (QLatin1String errorId, ErrorMessage &&err) |
static void | visitRegisteredMessages (function_ref< bool(const ErrorMessage &)> visitor) |
static ErrorMessage | load (QLatin1String errorId) |
static ErrorMessage | load (const char *errorId) |
template<typename... T> | |
static ErrorMessage | load (QLatin1String errorId, T... args) |
Public Attributes | |
QLatin1String | errorId |
QString | message |
ErrorGroups | errorGroups |
Level | level |
Path | path |
QString | file |
SourceLocation | location |
Friends | |
int | compare (const ErrorMessage &msg1, const ErrorMessage &msg2) |
Represents an error message connected to the dom.
The error messages should be translated, but they do not need to be pre registered. To give a meaningful handling of error messages ErrorMessages have "tags" (ErrorGroup) that are grouped toghether in ErrorGroups.
To create an ErrorMessage from scratch the best way is to use one of the methods provided by an ErrorGroups object. For example create an ErrorGroups called myErrors and use it to create all your errors.
You can preregister the errors giving them a unique name (reverse dns notation is encouraged) with the msg function. This unique name (errorId) is a const char* (QLatin1String) to integrate better with the tr function. Ideally you create variables to store the errorId either by creating variables with plain strings that you use to initialize the error messages
or using the result of the msg function
and then use them like this
or using directly the string (more error prone)
The \l{withItem} method can be used to set the path file and location if not aready set.
Definition at line 101 of file qqmldomerrormessage_p.h.
Definition at line 105 of file qqmldomerrormessage_p.h.
QQmlJS::Dom::ErrorMessage::ErrorMessage | ( | const QString & | message, |
const ErrorGroups & | errorGroups, | ||
Level | level = Level::Warning, | ||
const Path & | path = Path(), | ||
const QString & | file = QString(), | ||
SourceLocation | location = SourceLocation(), | ||
QLatin1String | errorId = QLatin1String("") ) |
Definition at line 255 of file qqmldomerrormessage.cpp.
References errorGroups, QQmlJS::Dom::ErrorGroups::fatal(), and msg().
QQmlJS::Dom::ErrorMessage::ErrorMessage | ( | const ErrorGroups & | errorGroups, |
const DiagnosticMessage & | msg, | ||
const Path & | path = Path(), | ||
const QString & | file = QString(), | ||
QLatin1String | errorId = QLatin1String("") ) |
Definition at line 270 of file qqmldomerrormessage.cpp.
References errorGroups, QQmlJS::Dom::ErrorGroups::fatal(), and msg().
Definition at line 429 of file qqmldomerrormessage.cpp.
References QQmlJS::Dom::ErrorGroups::dump(), QQmlJS::Dom::dumpErrorLevel(), errorGroups, errorId, file, QLatin1StringView::isEmpty(), QString::isEmpty(), and QQmlJS::Dom::sinkInt().
Referenced by toString().
ErrorMessage QQmlJS::Dom::ErrorMessage::handle | ( | const ErrorHandler & | errorHandler = nullptr | ) |
Definition at line 420 of file qqmldomerrormessage.cpp.
References QQmlJS::Dom::defaultErrorHandler().
|
static |
Definition at line 371 of file qqmldomerrormessage.cpp.
References errorId, and load().
|
static |
Definition at line 359 of file qqmldomerrormessage.cpp.
References errorId, QQmlJS::Dom::myErrors(), QQmlJS::Dom::registry(), and QQmlJS::Dom::registryMutex().
Referenced by load().
|
inlinestatic |
|
static |
Definition at line 321 of file qqmldomerrormessage.cpp.
References errorId, and msg().
Referenced by ErrorMessage(), ErrorMessage(), msg(), and msg().
|
static |
Definition at line 326 of file qqmldomerrormessage.cpp.
References arg, QQmlJS::Dom::defaultErrorHandler(), errorId, msg(), QQmlJS::Dom::myErrors(), QQmlJS::Dom::registry(), QQmlJS::Dom::registryMutex(), QLatin1StringView::toString(), toString(), tr, and warning().
QCborMap QQmlJS::Dom::ErrorMessage::toCbor | ( | ) | const |
Definition at line 464 of file qqmldomerrormessage.cpp.
References errorGroups, errorId, file, QStringLiteral, and QQmlJS::Dom::ErrorGroups::toCbor().
QString QQmlJS::Dom::ErrorMessage::toString | ( | ) | const |
Definition at line 459 of file qqmldomerrormessage.cpp.
References dump(), and QQmlJS::Dom::dumperToString().
Referenced by msg().
|
static |
Definition at line 344 of file qqmldomerrormessage.cpp.
References QSet< T >::cbegin(), it, QQmlJS::Dom::registry(), and QQmlJS::Dom::registryMutex().
ErrorMessage & QQmlJS::Dom::ErrorMessage::withErrorId | ( | QLatin1String | errorId | ) |
Definition at line 376 of file qqmldomerrormessage.cpp.
References errorId.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile | ( | const QString & | f | ) |
Definition at line 388 of file qqmldomerrormessage.cpp.
References file.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile | ( | QStringView | f | ) |
Definition at line 394 of file qqmldomerrormessage.cpp.
References file.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withItem | ( | const DomItem & | el | ) |
Definition at line 406 of file qqmldomerrormessage.cpp.
References el, file, QString::isEmpty(), QQmlJS::Dom::MainRegion, QQmlJS::Dom::FileLocations::region(), and QQmlJS::Dom::FileLocations::treeOf().
ErrorMessage & QQmlJS::Dom::ErrorMessage::withLocation | ( | SourceLocation | loc | ) |
Definition at line 400 of file qqmldomerrormessage.cpp.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withPath | ( | const Path & | path | ) |
Definition at line 382 of file qqmldomerrormessage.cpp.
References path.
|
friend |
Definition at line 139 of file qqmldomerrormessage_p.h.
ErrorGroups QQmlJS::Dom::ErrorMessage::errorGroups |
Definition at line 182 of file qqmldomerrormessage_p.h.
Referenced by ErrorMessage(), ErrorMessage(), dump(), and toCbor().
QLatin1String QQmlJS::Dom::ErrorMessage::errorId |
Definition at line 180 of file qqmldomerrormessage_p.h.
Referenced by dump(), load(), load(), msg(), msg(), toCbor(), and withErrorId().
QString QQmlJS::Dom::ErrorMessage::file |
Definition at line 185 of file qqmldomerrormessage_p.h.
Referenced by dump(), toCbor(), withFile(), withFile(), and withItem().
Level QQmlJS::Dom::ErrorMessage::level |
Definition at line 183 of file qqmldomerrormessage_p.h.
SourceLocation QQmlJS::Dom::ErrorMessage::location |
Definition at line 186 of file qqmldomerrormessage_p.h.
QString QQmlJS::Dom::ErrorMessage::message |
Definition at line 181 of file qqmldomerrormessage_p.h.
Path QQmlJS::Dom::ErrorMessage::path |
Definition at line 184 of file qqmldomerrormessage_p.h.
Referenced by withPath().