- try (var dBusConn = DBusConnection.getConnection(busType)) {
- var ts = dBusConn.getRemoteObject(DbusConfig.getBusname(),
- DbusConfig.getObjectPath(username),
- Signal.class);
-
- handleCommand(command, ts, dBusConn, outputWriter);
- }
- } catch (DBusException | IOException e) {
- logger.error("Dbus client failed", e);
- throw new UnexpectedErrorException("Dbus client failed", e);
- }
- }
-
- private void handleCommand(
- Command command, Signal ts, DBusConnection dBusConn, OutputWriter outputWriter
- ) throws CommandException {
- if (command instanceof ExtendedDbusCommand) {
- ((ExtendedDbusCommand) command).handleCommand(ns, ts, dBusConn, outputWriter);
- } else if (command instanceof DbusCommand) {
- ((DbusCommand) command).handleCommand(ns, ts, outputWriter);
- } else {
- throw new UserErrorException("Command is not yet implemented via dbus");
+ } catch (ServiceUnknown e) {
+ throw new UserErrorException("signal-cli DBus daemon not running on "
+ + (systemBus ? "system" : "session")
+ + " bus: "
+ + e.getMessage(), e);
+ } catch (DBusExecutionException | DBusException | IOException e) {
+ throw new UnexpectedErrorException("Dbus client failed: " + e.getMessage(), e);