- 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;
+ throw new UserErrorException("Failed to send to group: " + e.getMessage());
+ } catch (LastGroupAdminException e) {
+ throw new UserErrorException("You need to specify a new admin with --admin: " + e.getMessage());
+ }
+ }
+
+ private void outputResult(final OutputWriter outputWriter, 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));