mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Fix exceptions to work over dbus
This commit is contained in:
parent
2a0f9f7629
commit
3d56067272
3 changed files with 18 additions and 19 deletions
|
@ -1,14 +1,13 @@
|
|||
package org.asamk.textsecure;
|
||||
|
||||
public class AttachmentInvalidException extends Exception {
|
||||
private final String attachment;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
|
||||
public class AttachmentInvalidException extends DBusExecutionException {
|
||||
public AttachmentInvalidException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public AttachmentInvalidException(String attachment, Exception e) {
|
||||
super(e);
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
public String getAttachment() {
|
||||
return attachment;
|
||||
super(attachment + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package org.asamk.textsecure;
|
||||
|
||||
public class GroupNotFoundException extends Exception {
|
||||
private final byte[] groupId;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
|
||||
public class GroupNotFoundException extends DBusExecutionException {
|
||||
|
||||
public GroupNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public GroupNotFoundException(byte[] groupId) {
|
||||
super();
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public byte[] getGroupId() {
|
||||
return groupId;
|
||||
super("Group not found: " + Base64.encodeBytes(groupId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class Main {
|
|||
} 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);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class Main {
|
|||
} 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) {
|
||||
|
@ -319,7 +319,7 @@ public class Main {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue