/*
* Copyright (c) 2012 Novell, Inc.
+ * Copyright (c) 2023 SUSE LLC
*
* All Rights Reserved.
*
conn = dbus_bus_get(type, &err);
if (dbus_error_is_set(&err))
{
- dbus_error_free(&err);
- SN_THROW(FatalException());
+ SN_THROW(ErrorException(&err));
}
if (!conn)
int ret = dbus_bus_request_name(conn, name, flags, &err);
if (dbus_error_is_set(&err))
{
- dbus_error_free(&err);
- SN_THROW(FatalException());
+ SN_THROW(ErrorException(&err));
}
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
0x7fffffff, &err);
if (dbus_error_is_set(&err))
{
- SN_THROW(ErrorException(err));
+ SN_THROW(ErrorException(&err));
}
return Message(tmp, false);
unsigned long uid = dbus_bus_get_unix_user(conn, sender.c_str(), &err);
if (dbus_error_is_set(&err))
{
- dbus_error_free(&err);
- SN_THROW(FatalException());
+ SN_THROW(ErrorException(&err));
}
return uid;
/*
* Copyright (c) 2012 Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016-2023] SUSE LLC
*
* All Rights Reserved.
*
struct ErrorException : public Exception
{
- explicit ErrorException(const DBusError err)
- : Exception("dbus error exception"), err(err) {}
- virtual ~ErrorException() { dbus_error_free(&err); }
- virtual const char* name() const { return err.name; }
- virtual const char* message() const { return err.message; }
- DBusError err;
+ explicit ErrorException(DBusError* err)
+ : Exception("dbus error exception"), err_name(err->name), err_message(err->message)
+ {
+ dbus_error_free(err);
+ }
+
+ const char* name() const { return err_name.c_str(); }
+ const char* message() const { return err_message.c_str(); }
+
+ const string err_name;
+ const string err_message;
};