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>.
Loading...
Searching...
No Matches
QQmlJS::Dom::ErrorMessage Class Reference

Represents an error message connected to the dom. More...

#include <qqmldomerrormessage_p.h>

+ Collaboration diagram for QQmlJS::Dom::ErrorMessage:

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(""))
 
ErrorMessagewithErrorId (QLatin1String errorId)
 
ErrorMessagewithPath (const Path &)
 
ErrorMessagewithFile (const QString &)
 
ErrorMessagewithFile (QStringView)
 
ErrorMessagewithLocation (SourceLocation)
 
ErrorMessagewithItem (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)
 

Detailed Description

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.

static ErrorGroups res({NewErrorGroup("StaticAnalysis"), NewErrorGroup("FancyDetector")});
return res;
}
Represents a set of tags grouping a set of related error messages.
static ErrorGroups myErrors()
GLuint res
#define NewErrorGroup(name)

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

// in .h file
constexpr const char *myError0 = "my.company.error0";
// in some initialization function
ErrorMessage::msg(myError0, myErrors().warning(tr("Error number 0")));
static QLatin1String msg(const char *errorId, ErrorMessage &&err)
QDebug warning(QAnyStringView fileName, int lineNumber)
#define tr(X)

or using the result of the msg function

// in cpp file
static auto myError1 = ErrorMessage::msg("my.company.error1", myErrors().warning(tr("Error number 1")));
static auto myError2 = ErrorMessage::msg("my.company.error2", myErrors().error(tr("Error number 2 on %1")));
DBusConnection const char DBusError * error

and then use them like this

ErrorMessage::load(myError2, QLatin1String("extra info")).handle(errorHandler);
static ErrorMessage load(QLatin1String errorId)
QLatin1StringView QLatin1String
Definition qstringfwd.h:31

or using directly the string (more error prone)

errorHandler(ErrorMessage::load(QLatin1String("my.company.error1")));

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.

Member Typedef Documentation

◆ Level

Constructor & Destructor Documentation

◆ ErrorMessage() [1/2]

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().

+ Here is the call graph for this function:

◆ ErrorMessage() [2/2]

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().

+ Here is the call graph for this function:

Member Function Documentation

◆ dump()

void QQmlJS::Dom::ErrorMessage::dump ( const Sink & s) const

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handle()

ErrorMessage QQmlJS::Dom::ErrorMessage::handle ( const ErrorHandler & errorHandler = nullptr)

Definition at line 420 of file qqmldomerrormessage.cpp.

References QQmlJS::Dom::defaultErrorHandler().

+ Here is the call graph for this function:

◆ load() [1/3]

ErrorMessage QQmlJS::Dom::ErrorMessage::load ( const char * errorId)
static

Definition at line 371 of file qqmldomerrormessage.cpp.

References errorId, and load().

+ Here is the call graph for this function:

◆ load() [2/3]

ErrorMessage QQmlJS::Dom::ErrorMessage::load ( QLatin1String errorId)
static

Definition at line 359 of file qqmldomerrormessage.cpp.

References errorId, QQmlJS::Dom::myErrors(), QQmlJS::Dom::registry(), and QQmlJS::Dom::registryMutex().

Referenced by load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load() [3/3]

template<typename... T>
static ErrorMessage QQmlJS::Dom::ErrorMessage::load ( QLatin1String errorId,
T... args )
inlinestatic

Definition at line 113 of file qqmldomerrormessage_p.h.

References args, and load().

+ Here is the call graph for this function:

◆ msg() [1/2]

QLatin1String QQmlJS::Dom::ErrorMessage::msg ( const char * errorId,
ErrorMessage && err )
static

Definition at line 321 of file qqmldomerrormessage.cpp.

References errorId, and msg().

Referenced by ErrorMessage(), ErrorMessage(), msg(), and msg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msg() [2/2]

QLatin1String QQmlJS::Dom::ErrorMessage::msg ( QLatin1String errorId,
ErrorMessage && err )
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().

+ Here is the call graph for this function:

◆ toCbor()

QCborMap QQmlJS::Dom::ErrorMessage::toCbor ( ) const

Definition at line 464 of file qqmldomerrormessage.cpp.

References errorGroups, errorId, file, QStringLiteral, and QQmlJS::Dom::ErrorGroups::toCbor().

+ Here is the call graph for this function:

◆ toString()

QString QQmlJS::Dom::ErrorMessage::toString ( ) const

Definition at line 459 of file qqmldomerrormessage.cpp.

References dump(), and QQmlJS::Dom::dumperToString().

Referenced by msg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visitRegisteredMessages()

void QQmlJS::Dom::ErrorMessage::visitRegisteredMessages ( function_ref< bool(const ErrorMessage &)> visitor)
static

Definition at line 344 of file qqmldomerrormessage.cpp.

References QSet< T >::cbegin(), it, QQmlJS::Dom::registry(), and QQmlJS::Dom::registryMutex().

+ Here is the call graph for this function:

◆ withErrorId()

ErrorMessage & QQmlJS::Dom::ErrorMessage::withErrorId ( QLatin1String errorId)

Definition at line 376 of file qqmldomerrormessage.cpp.

References errorId.

◆ withFile() [1/2]

ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile ( const QString & f)

Definition at line 388 of file qqmldomerrormessage.cpp.

References file.

◆ withFile() [2/2]

ErrorMessage & QQmlJS::Dom::ErrorMessage::withFile ( QStringView f)

Definition at line 394 of file qqmldomerrormessage.cpp.

References file.

◆ withItem()

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().

+ Here is the call graph for this function:

◆ withLocation()

ErrorMessage & QQmlJS::Dom::ErrorMessage::withLocation ( SourceLocation loc)

Definition at line 400 of file qqmldomerrormessage.cpp.

◆ withPath()

ErrorMessage & QQmlJS::Dom::ErrorMessage::withPath ( const Path & path)

Definition at line 382 of file qqmldomerrormessage.cpp.

References path.

Friends And Related Symbol Documentation

◆ compare

int compare ( const ErrorMessage & msg1,
const ErrorMessage & msg2 )
friend

Definition at line 139 of file qqmldomerrormessage_p.h.

Member Data Documentation

◆ errorGroups

ErrorGroups QQmlJS::Dom::ErrorMessage::errorGroups

Definition at line 182 of file qqmldomerrormessage_p.h.

Referenced by ErrorMessage(), ErrorMessage(), dump(), and toCbor().

◆ errorId

QLatin1String QQmlJS::Dom::ErrorMessage::errorId

Definition at line 180 of file qqmldomerrormessage_p.h.

Referenced by dump(), load(), load(), msg(), msg(), toCbor(), and withErrorId().

◆ file

QString QQmlJS::Dom::ErrorMessage::file

Definition at line 185 of file qqmldomerrormessage_p.h.

Referenced by dump(), toCbor(), withFile(), withFile(), and withItem().

◆ level

Level QQmlJS::Dom::ErrorMessage::level

Definition at line 183 of file qqmldomerrormessage_p.h.

◆ location

SourceLocation QQmlJS::Dom::ErrorMessage::location

Definition at line 186 of file qqmldomerrormessage_p.h.

◆ message

QString QQmlJS::Dom::ErrorMessage::message

Definition at line 181 of file qqmldomerrormessage_p.h.

◆ path

Path QQmlJS::Dom::ErrorMessage::path

Definition at line 184 of file qqmldomerrormessage_p.h.

Referenced by withPath().


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