[−][src]Derive Macro zbus::DBusError
#[derive(DBusError)] { // Attributes available to this derive: #[dbus_error] }
Derive macro for defining a D-Bus error.
This macro helps to implement an Error
suitable for D-Bus handling with zbus. It will expand
an enum E
with Error
traits implementation, and From<zbus::Error>
. The latter makes it
possible for you to declare proxy methods to directly return this type, rather than
zbus::Error
. However, for this to work, we require a variant by the name ZBus
that
contains an unnamed field of type zbus::Error
.
Additionnally, the derived impl E
will provide the following convenience methods:
-
name(&self)
- get the associated D-Bus error name. -
description(&self)
- get the associated error description (the first argument of an error message) -
reply(&self, &zbus::Connection, &zbus::Message)
- send this error as reply to the message.
Note: it is recommended that errors take a single argument String
which describes it in
a human-friendly fashion (support for other arguments is limited or TODO currently).
Example
use zbus_macros::DBusError; #[derive(DBusError, Debug)] #[dbus_error(prefix = "org.myservice.App")] enum Error { ZBus(zbus::Error), FileNotFound(String), OutOfMemory, }