package org.asamk.textsecure;
-public class AttachmentInvalidException extends Exception {
- private final String attachment;
+import org.freedesktop.dbus.exceptions.DBusExecutionException;
- public AttachmentInvalidException(String attachment, Exception e) {
- super(e);
- this.attachment = attachment;
+public class AttachmentInvalidException extends DBusExecutionException {
+ public AttachmentInvalidException(String message) {
+ super(message);
}
- public String getAttachment() {
- return attachment;
+ public AttachmentInvalidException(String attachment, Exception e) {
+ super(attachment + ": " + e.getMessage());
}
}
package org.asamk.textsecure;
-public class GroupNotFoundException extends Exception {
- private final byte[] groupId;
+import org.freedesktop.dbus.exceptions.DBusExecutionException;
- public GroupNotFoundException(byte[] groupId) {
- super();
- this.groupId = groupId;
+public class GroupNotFoundException extends DBusExecutionException {
+
+ public GroupNotFoundException(String message) {
+ super(message);
}
- public byte[] getGroupId() {
- return groupId;
+ public GroupNotFoundException(byte[] groupId) {
+ super("Group not found: " + Base64.encodeBytes(groupId));
}
}
} catch (GroupNotFoundException e) {
handleGroupNotFoundException(e);
} catch (AttachmentInvalidException e) {
- System.err.println("Failed to add attachment (\"" + e.getAttachment() + "\"): " + e.getMessage());
+ System.err.println("Failed to add attachment: " + e.getMessage());
System.err.println("Aborting sending.");
System.exit(1);
}
} catch (IOException e) {
handleIOException(e);
} catch (AttachmentInvalidException e) {
- System.err.println("Failed to add avatar attachment (\"" + e.getAttachment() + ") for group\": " + e.getMessage());
+ System.err.println("Failed to add avatar attachment for group\": " + e.getMessage());
System.err.println("Aborting sending.");
System.exit(1);
} catch (GroupNotFoundException e) {
}
private static void handleGroupNotFoundException(GroupNotFoundException e) {
- System.err.println("Failed to send to group \"" + Base64.encodeBytes(e.getGroupId()) + "\": Unknown group");
+ System.err.println("Failed to send to group: " + e.getMessage());
System.err.println("Aborting sending.");
System.exit(1);
}