:right-sidebar: True DBusError =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.26 .. class:: DBusError :no-contents-entry: Error codes for the %G_DBUS_ERROR error domain. Methods ------- .. rst-class:: interim-class .. class:: DBusError :no-index: .. method:: encode_gerror() -> str Creates a D-Bus error name to use for ``error``\. If ``error`` matches a registered error (see :obj:`~gi.repository.Gio.DBusError.register_error`\), the corresponding D-Bus error name will be returned. Otherwise the a name of the form ``org.gtk.GDBus.UnmappedGError.Quark._ESCAPED_QUARK_NAME.Code_ERROR_CODE`` will be used. This allows other GDBus applications to map the error on the wire back to a :obj:`~gi.repository.GLib.Error` using :obj:`~gi.repository.Gio.DBusError.new_for_dbus_error`\. This function is typically only used in object mappings to put a :obj:`~gi.repository.GLib.Error` on the wire. Regular applications should not use it. .. versionadded:: 2.26 .. method:: get_remote_error() -> str | None Gets the D-Bus error name used for ``error``\, if any. This function is guaranteed to return a D-Bus error name for all :obj:`~gi.repository.GLib.Error`\s returned from functions handling remote method calls (for example, :obj:`~gi.repository.Gio.DBusConnection.call_finish`\) unless :obj:`~gi.repository.Gio.DBusError.strip_remote_error` has already been used on ``error``\. .. versionadded:: 2.26 .. method:: is_remote_error() -> bool Checks if ``error`` represents an error received via D-Bus from a remote peer. If so, use :obj:`~gi.repository.Gio.DBusError.get_remote_error` to get the name of the error. .. versionadded:: 2.26 .. method:: new_for_dbus_error(dbus_error_message: str) -> ~gi.repository.GLib.GError Creates a :obj:`~gi.repository.GLib.Error` based on the contents of ``dbus_error_name`` and ``dbus_error_message``\. Errors registered with :obj:`~gi.repository.Gio.DBusError.register_error` will be looked up using ``dbus_error_name`` and if a match is found, the error domain and code is used. Applications can use :obj:`~gi.repository.Gio.DBusError.get_remote_error` to recover ``dbus_error_name``\. If a match against a registered error is not found and the D-Bus error name is in a form as returned by :obj:`~gi.repository.Gio.DBusError.encode_gerror` the error domain and code encoded in the name is used to create the :obj:`~gi.repository.GLib.Error`\. Also, ``dbus_error_name`` is added to the error message such that it can be recovered with :obj:`~gi.repository.Gio.DBusError.get_remote_error`\. Otherwise, a :obj:`~gi.repository.GLib.Error` with the error code :obj:`~gi.repository.Gio.IOErrorEnum.DBUS_ERROR` in the :obj:`~gi.repository.Gio.IOErrorEnum` error domain is returned. Also, ``dbus_error_name`` is added to the error message such that it can be recovered with :obj:`~gi.repository.Gio.DBusError.get_remote_error`\. In all three cases, ``dbus_error_name`` can always be recovered from the returned :obj:`~gi.repository.GLib.Error` using the :obj:`~gi.repository.Gio.DBusError.get_remote_error` function (unless :obj:`~gi.repository.Gio.DBusError.strip_remote_error` hasn’t been used on the returned error). This function is typically only used in object mappings to prepare :obj:`~gi.repository.GLib.Error` instances for applications. Regular applications should not use it. .. versionadded:: 2.26 :param dbus_error_message: D-Bus error message .. method:: quark() -> int .. method:: register_error(error_code: int, dbus_error_name: str) -> bool Creates an association mapping between ``dbus_error_name`` and :obj:`~gi.repository.GLib.Error`\s specified by ``error_domain`` and ``error_code``\. This is typically done in the function that returns the :obj:`~gi.repository.GLib.Quark` for an error domain. .. versionadded:: 2.26 :param error_code: an error code :param dbus_error_name: a D-Bus error name .. method:: register_error_domain(entries: list[~gi.repository.Gio.DBusErrorEntry]) -> int Helper function for associating a :obj:`~gi.repository.GLib.Error` error domain with D-Bus error names. While ``quark_volatile`` has a ``volatile`` qualifier, this is a historical artifact and the argument passed to it should not be ``volatile``\. .. versionadded:: 2.26 :param entries: items to register .. method:: strip_remote_error() -> bool Looks for extra information in the error message used to recover the D-Bus error name and strips it if found. If stripped, the message field in ``error`` will correspond exactly to what was received on the wire. This is typically used when presenting errors to the end user. .. versionadded:: 2.26 .. method:: unregister_error(error_code: int, dbus_error_name: str) -> bool Destroys an association previously set up with :obj:`~gi.repository.Gio.DBusError.register_error`\. .. versionadded:: 2.26 :param error_code: an error code :param dbus_error_name: a D-Bus error name Fields ------ .. rst-class:: interim-class .. class:: DBusError :no-index: .. attribute:: ACCESS_DENIED Security restrictions don't allow doing what you're trying to do. .. attribute:: ADDRESS_IN_USE Can't bind a socket since its address is in use (i.e. EADDRINUSE). .. attribute:: ADT_AUDIT_DATA_UNKNOWN Asked for ADT audit data and it wasn't available. .. attribute:: AUTH_FAILED Authentication didn't work. .. attribute:: BAD_ADDRESS A D-Bus bus address was malformed. .. attribute:: DISCONNECTED The connection is disconnected and you're trying to use it. .. attribute:: FAILED A generic error; "something went wrong" - see the error message for more. .. attribute:: FILE_EXISTS Existing file and the operation you're using does not silently overwrite. .. attribute:: FILE_NOT_FOUND Missing file. .. attribute:: INVALID_ARGS Invalid arguments passed to a method call. .. attribute:: INVALID_FILE_CONTENT A file contains invalid syntax or is otherwise broken. .. attribute:: INVALID_SIGNATURE A type signature is not valid. .. attribute:: IO_ERROR Something went wrong reading or writing to a socket, for example. .. attribute:: LIMITS_EXCEEDED Some limited resource is exhausted. .. attribute:: MATCH_RULE_INVALID The match rule isn't syntactically valid. .. attribute:: MATCH_RULE_NOT_FOUND Tried to remove or modify a match rule that didn't exist. .. attribute:: NAME_HAS_NO_OWNER The bus name you referenced doesn't exist (i.e. no application owns it). .. attribute:: NOT_SUPPORTED Requested operation isn't supported (like ENOSYS on UNIX). .. attribute:: NO_MEMORY There was not enough memory to complete an operation. .. attribute:: NO_NETWORK No network access (probably ENETUNREACH on a socket). .. attribute:: NO_REPLY No reply to a message expecting one, usually means a timeout occurred. .. attribute:: NO_SERVER Unable to connect to server (probably caused by ECONNREFUSED on a socket). .. attribute:: OBJECT_PATH_IN_USE There's already an object with the requested object path. .. attribute:: PROPERTY_READ_ONLY Property you tried to set is read-only. Since 2.42 .. attribute:: SELINUX_SECURITY_CONTEXT_UNKNOWN Asked for SELinux security context and it wasn't available. .. attribute:: SERVICE_UNKNOWN The bus doesn't know how to launch a service to supply the bus name you wanted. .. attribute:: SPAWN_CHILD_EXITED While starting a new process, the child exited with a status code. .. attribute:: SPAWN_CHILD_SIGNALED While starting a new process, the child exited on a signal. .. attribute:: SPAWN_CONFIG_INVALID We failed to setup the config parser correctly. .. attribute:: SPAWN_EXEC_FAILED While starting a new process, the exec() call failed. .. attribute:: SPAWN_FAILED While starting a new process, something went wrong. .. attribute:: SPAWN_FILE_INVALID Service file invalid (Name, User or Exec missing). .. attribute:: SPAWN_FORK_FAILED While starting a new process, the fork() call failed. .. attribute:: SPAWN_NO_MEMORY Tried to get a UNIX process ID and it wasn't available. .. attribute:: SPAWN_PERMISSIONS_INVALID Permissions are incorrect on the setuid helper. .. attribute:: SPAWN_SERVICE_INVALID Bus name was not valid. .. attribute:: SPAWN_SERVICE_NOT_FOUND Service file not found in system-services directory. .. attribute:: SPAWN_SETUP_FAILED We failed to setup the environment correctly. .. attribute:: TIMED_OUT Certain timeout errors, e.g. while starting a service. Warning: this is confusingly-named given that :const:`~gi.repository.Gio.DBusError.TIMEOUT` also exists. We can't fix it for compatibility reasons so just be careful. .. attribute:: TIMEOUT Certain timeout errors, possibly ETIMEDOUT on a socket. Note that :const:`~gi.repository.Gio.DBusError.NO_REPLY` is used for message reply timeouts. Warning: this is confusingly-named given that :const:`~gi.repository.Gio.DBusError.TIMED_OUT` also exists. We can't fix it for compatibility reasons so just be careful. .. attribute:: UNIX_PROCESS_ID_UNKNOWN Tried to get a UNIX process ID and it wasn't available. .. attribute:: UNKNOWN_INTERFACE Interface you invoked a method on isn't known by the object. Since 2.42 .. attribute:: UNKNOWN_METHOD Method name you invoked isn't known by the object you invoked it on. .. attribute:: UNKNOWN_OBJECT Object you invoked a method on isn't known. Since 2.42 .. attribute:: UNKNOWN_PROPERTY Property you tried to access isn't known by the object. Since 2.42