![]() |
Qt 6.x
The Qt SDK
|
Represents an error message connected to the dom. More...
#include <qqmldomerrormessage_p.h>
Public Types | |
using | Level = ErrorLevel |
Public Member Functions | |
ErrorMessage (QString message, ErrorGroups errorGroups, Level level=Level::Warning, Path path=Path(), QString file=QString(), SourceLocation location=SourceLocation(), QLatin1String errorId=QLatin1String("")) | |
ErrorMessage (ErrorGroups errorGroups, const DiagnosticMessage &msg, Path path=Path(), QString file=QString(), QLatin1String errorId=QLatin1String("")) | |
ErrorMessage & | withErrorId (QLatin1String errorId) |
ErrorMessage & | withPath (const Path &) |
ErrorMessage & | withFile (QString) |
ErrorMessage & | withFile (QStringView) |
ErrorMessage & | withLocation (SourceLocation) |
ErrorMessage & | withItem (DomItem) |
ErrorMessage | handle (const ErrorHandler &errorHandler=nullptr) |
void | dump (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(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 96 of file qqmldomerrormessage_p.h.
Definition at line 100 of file qqmldomerrormessage_p.h.
QQmlJS::Dom::ErrorMessage::ErrorMessage | ( | QString | message, |
ErrorGroups | errorGroups, | ||
Level | level = Level::Warning , |
||
Path | path = Path() , |
||
QString | file = QString() , |
||
SourceLocation | location = SourceLocation() , |
||
QLatin1String | errorId = QLatin1String("") |
||
) |
Definition at line 251 of file qqmldomerrormessage.cpp.
References errorGroups, QQmlJS::Dom::ErrorGroups::fatal(), and msg().
QQmlJS::Dom::ErrorMessage::ErrorMessage | ( | ErrorGroups | errorGroups, |
const DiagnosticMessage & | msg, | ||
Path | path = Path() , |
||
QString | file = QString() , |
||
QLatin1String | errorId = QLatin1String("") |
||
) |
Definition at line 258 of file qqmldomerrormessage.cpp.
References errorGroups, QQmlJS::Dom::ErrorGroups::fatal(), and msg().
Definition at line 407 of file qqmldomerrormessage.cpp.
References QQmlJS::Dom::ErrorGroups::dump(), QQmlJS::Dom::dumpErrorLevel(), errorGroups, errorId, file, QString::isEmpty(), QLatin1StringView::isEmpty(), and QQmlJS::Dom::sinkInt().
Referenced by toString().
ErrorMessage QQmlJS::Dom::ErrorMessage::handle | ( | const ErrorHandler & | errorHandler = nullptr | ) |
Definition at line 398 of file qqmldomerrormessage.cpp.
References QQmlJS::Dom::defaultErrorHandler().
Referenced by QQmlJS::Dom::DomUniverse::execQueue(), QQmlJS::Dom::Path::fromString(), QQmlJS::Dom::Paths::moduleIndexPath(), and QQmlJS::Dom::Paths::moduleScopePath().
|
static |
Definition at line 349 of file qqmldomerrormessage.cpp.
References errorId, and load().
|
static |
Definition at line 337 of file qqmldomerrormessage.cpp.
References QQmlJS::Dom::ErrorGroups::error(), errorId, QQmlJS::Dom::myErrors(), QQmlJS::Dom::registry(), and QQmlJS::Dom::registryMutex().
Referenced by load().
|
inlinestatic |
|
static |
Definition at line 299 of file qqmldomerrormessage.cpp.
References errorId, and msg().
Referenced by ErrorMessage(), ErrorMessage(), msg(), and msg().
|
static |
Definition at line 304 of file qqmldomerrormessage.cpp.
References arg, QQmlJS::Dom::ErrorGroups::debug(), QQmlJS::Dom::defaultErrorHandler(), errorId, msg(), QQmlJS::Dom::myErrors(), QQmlJS::Dom::registry(), QQmlJS::Dom::registryMutex(), toString(), tr, and withErrorId().
QCborMap QQmlJS::Dom::ErrorMessage::toCbor | ( | ) | const |
Definition at line 442 of file qqmldomerrormessage.cpp.
References errorGroups, errorId, file, QStringLiteral, and QQmlJS::Dom::ErrorGroups::toCbor().
QString QQmlJS::Dom::ErrorMessage::toString | ( | ) | const |
Definition at line 437 of file qqmldomerrormessage.cpp.
References dump(), and QQmlJS::Dom::dumperToString().
Referenced by msg().
|
static |
Definition at line 322 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 354 of file qqmldomerrormessage.cpp.
References errorId.
Referenced by msg().
ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile | ( | QString | f | ) |
Definition at line 366 of file qqmldomerrormessage.cpp.
References file.
Referenced by QQmlJS::Dom::QmlFile::QmlFile().
ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile | ( | QStringView | f | ) |
Definition at line 372 of file qqmldomerrormessage.cpp.
References file.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withItem | ( | DomItem | el | ) |
Definition at line 384 of file qqmldomerrormessage.cpp.
References el, file, QQmlJS::Dom::FileLocations::fileLocationsOf(), and QString::isEmpty().
ErrorMessage & QQmlJS::Dom::ErrorMessage::withLocation | ( | SourceLocation | loc | ) |
Definition at line 378 of file qqmldomerrormessage.cpp.
ErrorMessage & QQmlJS::Dom::ErrorMessage::withPath | ( | const Path & | path | ) |
Definition at line 360 of file qqmldomerrormessage.cpp.
References path.
Referenced by QQmlJS::Dom::QmlFile::QmlFile(), and QQmlJS::Dom::ModuleIndex::exportsWithNameAndMinorVersion().
|
friend |
Definition at line 129 of file qqmldomerrormessage_p.h.
ErrorGroups QQmlJS::Dom::ErrorMessage::errorGroups |
Definition at line 172 of file qqmldomerrormessage_p.h.
Referenced by ErrorMessage(), ErrorMessage(), dump(), and toCbor().
QLatin1String QQmlJS::Dom::ErrorMessage::errorId |
Definition at line 170 of file qqmldomerrormessage_p.h.
Referenced by QmlLsp::QmlLintSuggestions::diagnose(), dump(), load(), load(), msg(), msg(), toCbor(), and withErrorId().
QString QQmlJS::Dom::ErrorMessage::file |
Definition at line 175 of file qqmldomerrormessage_p.h.
Referenced by dump(), toCbor(), withFile(), withFile(), and withItem().
Level QQmlJS::Dom::ErrorMessage::level |
Definition at line 173 of file qqmldomerrormessage_p.h.
Referenced by QmlLsp::QmlLintSuggestions::diagnose().
SourceLocation QQmlJS::Dom::ErrorMessage::location |
Definition at line 176 of file qqmldomerrormessage_p.h.
Referenced by QmlLsp::QmlLintSuggestions::diagnose().
QString QQmlJS::Dom::ErrorMessage::message |
Definition at line 171 of file qqmldomerrormessage_p.h.
Referenced by QmlLsp::QmlLintSuggestions::diagnose().
Path QQmlJS::Dom::ErrorMessage::path |
Definition at line 174 of file qqmldomerrormessage_p.h.
Referenced by withPath().