Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | List of all members
QDBusError Class Reference

The QDBusError class represents an error received from the D-Bus bus or from remote applications found in the bus. More...

#include <qdbuserror.h>

Public Types

enum  ErrorType {
  NoError = 0, Other = 1, Failed, NoMemory,
  ServiceUnknown, NoReply, BadAddress, NotSupported,
  LimitsExceeded, AccessDenied, NoServer, Timeout,
  NoNetwork, AddressInUse, Disconnected, InvalidArgs,
  UnknownMethod, TimedOut, InvalidSignature, UnknownInterface,
  InternalError, UnknownObject, InvalidService, InvalidObjectPath,
  InvalidInterface, InvalidMember
}
 In order to facilitate verification of the most common D-Bus errors generated by the D-Bus implementation and by the bus daemon itself, QDBusError can be compared to a set of pre-defined values: More...
 

Public Functions

bool isValid () const
 Returns true if this is a valid error condition (i.e., if there was an error), otherwise false. More...
 
QString message () const
 Returns the message that the callee associated with this error. More...
 
QString name () const
 Returns this error's name. More...
 
QDBusErroroperator= (const QDBusError &other)
 
 QDBusError (const DBusError *error=0)
 Constructs a QDBusError from a DBusError structure. More...
 
 QDBusError (const QDBusMessage &msg)
 Constructs a QDBusError from a QDBusMessage. More...
 
 QDBusError (ErrorType error, const QString &message)
 
 QDBusError (const QDBusError &other)
 
ErrorType type () const
 Returns this error's ErrorType. More...
 

Static Public Functions

static QString errorString (ErrorType error)
 Returns the error name associated with error condition error. More...
 

Properties

ErrorType code
 
QString msg
 
QString nm
 
void * unused
 

Detailed Description

The QDBusError class represents an error received from the D-Bus bus or from remote applications found in the bus.

Attention
Module: QtDBus
Since
4.2

When dealing with the D-Bus bus service or with remote applications over D-Bus, a number of error conditions can happen. This error conditions are sometimes signalled by a returned error value or by a QDBusError.

C++ and Java exceptions are a valid analogy for D-Bus errors: instead of returning normally with a return value, remote applications and the bus may decide to throw an error condition. However, the QtDBus implementation does not use the C++ exception-throwing mechanism, so you will receive QDBusErrors in the return reply (see QDBusReply::error()).

QDBusError objects are used to inspect the error name and message as received from the bus and remote applications. You should not create such objects yourself to signal error conditions when called from D-Bus: instead, use QDBusMessage::createError() and QDBusConnection::send().

See also
QDBusConnection::send(), QDBusMessage, QDBusReply

Definition at line 60 of file qdbuserror.h.

Enumerations

◆ ErrorType

In order to facilitate verification of the most common D-Bus errors generated by the D-Bus implementation and by the bus daemon itself, QDBusError can be compared to a set of pre-defined values:

e., the call succeeded)

  • Other QDBusError contains an error that is one of the well-known ones
  • Failed The call failed (org.freedesktop.DBus.Error.Failed)
  • NoMemory Out of memory (org.freedesktop.DBus.Error.NoMemory)
  • ServiceUnknown The called service is not known (org.freedesktop.DBus.Error.ServiceUnknown)
  • NoReply The called method did not reply within the specified timeout (org.freedesktop.DBus.Error.NoReply)
  • BadAddress The address given is not valid (org.freedesktop.DBus.Error.BadAddress)
  • NotSupported The call/operation is not supported (org.freedesktop.DBus.Error.NotSupported)
  • LimitsExceeded The limits allocated to this process/call/connection exceeded the pre-defined values (org.freedesktop.DBus.Error.LimitsExceeded)
  • AccessDenied The call/operation tried to access a resource it isn't allowed to (org.freedesktop.DBus.Error.AccessDenied)
  • NoServer {Documentation doesn't say what this is for} (org.freedesktop.DBus.Error.NoServer)
  • Timeout {Documentation doesn't say what this is for or how it's used} (org.freedesktop.DBus.Error.Timeout)
  • NoNetwork {Documentation doesn't say what this is for} (org.freedesktop.DBus.Error.NoNetwork)
  • AddressInUse QDBusServer tried to bind to an address that is already in use (org.freedesktop.DBus.Error.AddressInUse)
  • Disconnected The call/process/message was sent after QDBusConnection disconnected (org.freedesktop.DBus.Error.Disconnected)
  • InvalidArgs The arguments passed to this call/operation are not valid (org.freedesktop.DBus.Error.InvalidArgs)
  • UnknownMethod The method called was not found in this object/interface with the given parameters (org.freedesktop.DBus.Error.UnknownMethod)
  • TimedOut {Documentation doesn't say...} (org.freedesktop.DBus.Error.TimedOut)
  • InvalidSignature The type signature is not valid or compatible (org.freedesktop.DBus.Error.InvalidSignature)
  • UnknownInterface The interface is not known
  • InternalError An internal error occurred (com.trolltech.QtDBus.Error.InternalError)
  • InvalidObjectPath The object path provided is invalid.
  • InvalidService The service requested is invalid.
  • InvalidMember The member is invalid.
  • InvalidInterface The interface is invalid.
  • UnknownObject The remote object could not be found.
Enumerator
NoError 
Other 
Failed 
NoMemory 
ServiceUnknown 
NoReply 
BadAddress 
NotSupported 
LimitsExceeded 
AccessDenied 
NoServer 
Timeout 
NoNetwork 
AddressInUse 
Disconnected 
InvalidArgs 
UnknownMethod 
TimedOut 
InvalidSignature 
UnknownInterface 
InternalError 
UnknownObject 
InvalidService 
InvalidObjectPath 
InvalidInterface 
InvalidMember 

Definition at line 63 of file qdbuserror.h.

63  {
64  NoError = 0,
65  Other = 1,
66  Failed,
67  NoMemory,
69  NoReply,
70  BadAddress,
74  NoServer,
75  Timeout,
76  NoNetwork,
81  TimedOut,
90 
91 #ifndef Q_QDOC
92  // don't use this one!
93  LastErrorType = InvalidMember
94 #endif
95  };

Constructors and Destructors

◆ QDBusError() [1/4]

QDBusError::QDBusError ( const DBusError *  error = 0)

Constructs a QDBusError from a DBusError structure.

Warning
This function is not part of the public interface.

Definition at line 255 of file qdbuserror.cpp.

256  : code(NoError)
257 {
258  if (!error || !q_dbus_error_is_set(error))
259  return;
260 
261  code = ::get(error->name);
262  msg = QString::fromUtf8(error->message);
263  nm = QString::fromUtf8(error->name);
264 }
#define error(msg)
QString msg
Definition: qdbuserror.h:112
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
QString nm
Definition: qdbuserror.h:113
static const char * get(QDBusError::ErrorType code)
Definition: qdbuserror.cpp:141
ErrorType code
Definition: qdbuserror.h:111

◆ QDBusError() [2/4]

QDBusError::QDBusError ( const QDBusMessage qdmsg)

Constructs a QDBusError from a QDBusMessage.

Warning
This function is not part of the public interface.

Definition at line 273 of file qdbuserror.cpp.

274  : code(NoError)
275 {
276  if (qdmsg.type() != QDBusMessage::ErrorMessage)
277  return;
278 
279  code = ::get(qdmsg.errorName().toUtf8().constData());
280  nm = qdmsg.errorName();
281  msg = qdmsg.errorMessage();
282 }
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
QString msg
Definition: qdbuserror.h:112
QString errorMessage() const
Returns the human-readable message associated with the error that was received.
QString nm
Definition: qdbuserror.h:113
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString errorName() const
Returns the name of the error that was received.
static const char * get(QDBusError::ErrorType code)
Definition: qdbuserror.cpp:141
MessageType type() const
Returns the message type.
ErrorType code
Definition: qdbuserror.h:111

◆ QDBusError() [3/4]

QDBusError::QDBusError ( ErrorType  error,
const QString mess 
)
Warning
This function is not part of the public interface. Constructs a QDBusError from a well-known error code

Definition at line 288 of file qdbuserror.cpp.

289  : code(error)
290 {
291  nm = QLatin1String(::get(error));
292  msg = mess;
293 }
#define error(msg)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString msg
Definition: qdbuserror.h:112
QString nm
Definition: qdbuserror.h:113
ErrorType code
Definition: qdbuserror.h:111

◆ QDBusError() [4/4]

QDBusError::QDBusError ( const QDBusError other)
Warning
This function is not part of the public interface. Constructs a QDBusError from another QDBusError object

Definition at line 299 of file qdbuserror.cpp.

300  : code(other.code), msg(other.msg), nm(other.nm)
301 {
302 }
QString msg
Definition: qdbuserror.h:112
QString nm
Definition: qdbuserror.h:113
ErrorType code
Definition: qdbuserror.h:111

Functions

◆ errorString()

QString QDBusError::errorString ( ErrorType  error)
static

Returns the error name associated with error condition error.

Since
4.3

Definition at line 368 of file qdbuserror.cpp.

Referenced by QDBusMessage::createError(), and QDBusMessage::createErrorReply().

369 {
370  return QLatin1String(::get(error));
371 }
#define error(msg)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ isValid()

bool QDBusError::isValid ( ) const

Returns true if this is a valid error condition (i.e., if there was an error), otherwise false.

Definition at line 356 of file qdbuserror.cpp.

Referenced by QDBusReply< QStringList >::isValid(), qDBusErrorToScriptValue(), QDBusInterfacePrivate::QDBusInterfacePrivate(), and qDBusReplyFill().

357 {
358  return (code != NoError);
359 }
ErrorType code
Definition: qdbuserror.h:111

◆ message()

QString QDBusError::message ( ) const

◆ name()

QString QDBusError::name ( ) const

Returns this error's name.

Error names are similar to D-Bus Interface names, like org.freedesktop.DBus.InvalidArgs.

See also
type()

Definition at line 335 of file qdbuserror.cpp.

Referenced by QDBusMessage::createError(), QDBusMessage::createErrorReply(), operator<<(), and qDBusErrorToScriptValue().

336 {
337  return nm;
338 }
QString nm
Definition: qdbuserror.h:113

◆ operator=()

QDBusError & QDBusError::operator= ( const QDBusError other)
Warning
This function is not part of the public interface. Assignment operator

Definition at line 309 of file qdbuserror.cpp.

310 {
311  code = other.code;
312  msg = other.msg;
313  nm = other.nm;
314  return *this;
315 }
QString msg
Definition: qdbuserror.h:112
QString nm
Definition: qdbuserror.h:113
ErrorType code
Definition: qdbuserror.h:111

◆ type()

QDBusError::ErrorType QDBusError::type ( ) const

Properties

◆ code

ErrorType QDBusError::code
private

Definition at line 111 of file qdbuserror.h.

Referenced by isValid(), operator=(), QDBusError(), and type().

◆ msg

QString QDBusError::msg
private

Definition at line 112 of file qdbuserror.h.

Referenced by message(), operator=(), and QDBusError().

◆ nm

QString QDBusError::nm
private

Definition at line 113 of file qdbuserror.h.

Referenced by name(), operator=(), and QDBusError().

◆ unused

void* QDBusError::unused
private

Definition at line 114 of file qdbuserror.h.


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