Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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(const MetaType &classDef)
#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);
ErrorMessage handle(const ErrorHandler &errorHandler=nullptr)
static ErrorMessage load(QLatin1String errorId)
QLatin1StringView QLatin1String
Definition qstringfwd.h:34

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 102 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 257 of file qqmldomerrormessage.cpp.

References ErrorMessage().

Referenced by ErrorMessage().

Here is the call graph for this function:
Here is the caller 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 272 of file qqmldomerrormessage.cpp.

References ErrorMessage().

Referenced by ErrorMessage().

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

Member Function Documentation

◆ dump()

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

Definition at line 432 of file qqmldomerrormessage.cpp.

◆ handle()

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

Definition at line 423 of file qqmldomerrormessage.cpp.

References QQmlJS::Dom::defaultErrorHandler().

Referenced by QQmlJS::Dom::LoadInfo::doCopy(), and QQmlJS::Dom::DomItem::resolve().

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

◆ load() [1/3]

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

Definition at line 374 of file qqmldomerrormessage.cpp.

References load().

Referenced by load(), and load().

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

◆ load() [2/3]

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

Definition at line 362 of file qqmldomerrormessage.cpp.

References QQmlJS::Dom::ErrorGroups::error(), QQmlJS::Dom::myErrors(), and QQmlJS::Dom::registryMutex().

Here is the call graph for this function:

◆ load() [3/3]

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

Definition at line 114 of file qqmldomerrormessage_p.h.

References 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 323 of file qqmldomerrormessage.cpp.

◆ msg() [2/2]

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

Definition at line 328 of file qqmldomerrormessage.cpp.

References QQmlJS::Dom::myErrors(), QQmlJS::Dom::registryMutex(), and QQmlJS::Dom::ErrorGroups::warning().

Here is the call graph for this function:

◆ toCbor()

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

Definition at line 467 of file qqmldomerrormessage.cpp.

◆ toString()

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

Definition at line 462 of file qqmldomerrormessage.cpp.

◆ visitRegisteredMessages()

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

Definition at line 347 of file qqmldomerrormessage.cpp.

References QQmlJS::Dom::registryMutex().

Here is the call graph for this function:

◆ withErrorId()

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

Definition at line 379 of file qqmldomerrormessage.cpp.

◆ withFile() [1/2]

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

Definition at line 391 of file qqmldomerrormessage.cpp.

◆ withFile() [2/2]

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

Definition at line 397 of file qqmldomerrormessage.cpp.

◆ withItem()

ErrorMessage & QQmlJS::Dom::ErrorMessage::withItem ( const DomItem & el)
nodiscard

Definition at line 409 of file qqmldomerrormessage.cpp.

◆ withLocation()

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

Definition at line 403 of file qqmldomerrormessage.cpp.

◆ withPath()

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

Definition at line 385 of file qqmldomerrormessage.cpp.

◆ compare

Member Data Documentation

◆ errorGroups

ErrorGroups QQmlJS::Dom::ErrorMessage::errorGroups

Definition at line 183 of file qqmldomerrormessage_p.h.

◆ errorId

QLatin1String QQmlJS::Dom::ErrorMessage::errorId

Definition at line 181 of file qqmldomerrormessage_p.h.

◆ file

QString QQmlJS::Dom::ErrorMessage::file

Definition at line 186 of file qqmldomerrormessage_p.h.

◆ level

Level QQmlJS::Dom::ErrorMessage::level

Definition at line 184 of file qqmldomerrormessage_p.h.

◆ location

SourceLocation QQmlJS::Dom::ErrorMessage::location

Definition at line 187 of file qqmldomerrormessage_p.h.

◆ message

QString QQmlJS::Dom::ErrorMessage::message

◆ path

Path QQmlJS::Dom::ErrorMessage::path

Definition at line 185 of file qqmldomerrormessage_p.h.


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