- handleTimestampAndSendMessageResults(results.first(), results.second());
- return 0;
- } catch (IOException e) {
- handleIOException(e);
- return 3;
- } catch (AssertionError e) {
- handleAssertionError(e);
- return 1;
- } catch (GroupNotFoundException e) {
- handleGroupNotFoundException(e);
- return 1;
- } catch (NotAGroupMemberException e) {
- handleNotAGroupMemberException(e);
- return 1;
- } catch (GroupIdFormatException e) {
- handleGroupIdFormatException(e);
- return 1;
- } catch (InvalidNumberException e) {
- handleInvalidNumberException(e);
- return 1;
+ outputResult(timestamp);
+ } catch (UnknownObject e) {
+ throw new UserErrorException("Failed to find dbus object, maybe missing the -u flag: " + e.getMessage());
+ } catch (Signal.Error.InvalidNumber e) {
+ throw new UserErrorException("Invalid number: " + e.getMessage());
+ } catch (Signal.Error.GroupNotFound e) {
+ throw new UserErrorException("Failed to send to group: " + e.getMessage());
+ } catch (DBusExecutionException e) {
+ throw new UnexpectedErrorException("Failed to send message: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
+ handleCommand(ns, new DbusSignalImpl(m, null));
+ }
+
+ private void outputResult(final long timestamp) {
+ if (outputWriter instanceof PlainTextWriter) {
+ final var writer = (PlainTextWriter) outputWriter;
+ writer.println("{}", timestamp);
+ } else {
+ final var writer = (JsonWriter) outputWriter;
+ writer.write(Map.of("timestamp", timestamp));