exit(EXIT_FAILURE);
}
- DBus::Connection conn(DBUS_BUS_SYSTEM);
+ try
+ {
+ DBus::Connection conn(DBUS_BUS_SYSTEM);
- (*cmd->second)(conn);
+ (*cmd->second)(conn);
+ }
+ catch (const DBus::ErrorException& e)
+ {
+ if (strcmp(e.name(), "error.no_permissions") == 0)
+ cerr << "failed (no permissions)" << endl;
+ else
+ cerr << "failed (" << e.what() << ")" << endl;
+ }
+ catch (const DBus::FatalException& e)
+ {
+ cerr << "failed (" << e.what() << ")" << endl;
+ }
exit(EXIT_SUCCESS);
}
0x7fffffff, &err);
if (dbus_error_is_set(&err))
{
- dbus_error_free(&err);
- throw FatalException();
+ throw ErrorException(err);
}
Message reply(tmp);
};
+ struct ErrorException : public Exception
+ {
+ explicit ErrorException(const DBusError err) throw() : err(err) {}
+ ~ErrorException() throw() { dbus_error_free(&err); }
+ virtual const char* what() const throw() { return "dbus error exception"; }
+ virtual const char* name() const throw() { return err.name; }
+ virtual const char* message() const throw() { return err.message; }
+ DBusError err;
+ };
+
+
struct MarshallingException : public Exception
{
explicit MarshallingException() throw() {}