- 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 LocalCommand localCommand) {
- try (final var m = new DbusManagerImpl(ts, dBusConn)) {
- localCommand.handleCommand(ns, m, outputWriter);
- } catch (UnsupportedOperationException e) {
- throw new UserErrorException("Command is not yet implemented via dbus", e);
- } catch (IOException | DBusExecutionException e) {
- throw new UnexpectedErrorException(e.getMessage(), e);
- }
- } 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);